mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-15 06:45:42 -04:00
Fixed a lot of bugs
This commit is contained in:
parent
98282fd319
commit
d20d06ace7
@ -29,7 +29,7 @@ if (!hasProperty('mainClass')) {
|
|||||||
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".10" : "."+System.getenv("BUILD_NUMBER")
|
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".10" : "."+System.getenv("BUILD_NUMBER")
|
||||||
|
|
||||||
String mavenGroupId = 'HMCL'
|
String mavenGroupId = 'HMCL'
|
||||||
String mavenVersion = '2.4.0' + buildnumber
|
String mavenVersion = '2.3.5' + buildnumber
|
||||||
String bundleName = "Hello Minecraft! Launcher"
|
String bundleName = "Hello Minecraft! Launcher"
|
||||||
|
|
||||||
group = mavenGroupId
|
group = mavenGroupId
|
||||||
|
@ -96,7 +96,10 @@ public class YggdrasilAuthentication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public GameProfile[] getAvailableProfiles() {
|
public GameProfile[] getAvailableProfiles() {
|
||||||
return profiles.clone();
|
if (profiles == null)
|
||||||
|
return null;
|
||||||
|
else
|
||||||
|
return profiles.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAuthenticatedToken() {
|
public String getAuthenticatedToken() {
|
||||||
|
@ -50,6 +50,8 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
|
|||||||
protected final MinecraftVersion version;
|
protected final MinecraftVersion version;
|
||||||
|
|
||||||
public AbstractMinecraftLoader(LaunchOptions options, IMinecraftService service, String versionId, UserProfileProvider lr) throws GameException {
|
public AbstractMinecraftLoader(LaunchOptions options, IMinecraftService service, String versionId, UserProfileProvider lr) throws GameException {
|
||||||
|
if (service.version().getVersionById(versionId) == null)
|
||||||
|
throw new GameException("No version: " + versionId);
|
||||||
this.lr = lr;
|
this.lr = lr;
|
||||||
|
|
||||||
this.options = options;
|
this.options = options;
|
||||||
|
@ -18,6 +18,7 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.core.launch;
|
package org.jackhuang.hellominecraft.launcher.core.launch;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.HashSet;
|
||||||
import org.jackhuang.hellominecraft.util.C;
|
import org.jackhuang.hellominecraft.util.C;
|
||||||
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
import org.jackhuang.hellominecraft.launcher.core.auth.IAuthenticator;
|
||||||
@ -40,8 +41,13 @@ public class DefaultGameLauncher extends GameLauncher {
|
|||||||
downloadLibrariesEvent.register((sender, t) -> {
|
downloadLibrariesEvent.register((sender, t) -> {
|
||||||
final TaskWindow.TaskWindowFactory dw = TaskWindow.factory();
|
final TaskWindow.TaskWindowFactory dw = TaskWindow.factory();
|
||||||
ParallelTask parallelTask = new ParallelTask();
|
ParallelTask parallelTask = new ParallelTask();
|
||||||
for (DownloadLibraryJob s : t)
|
HashSet<String> names = new HashSet<>();
|
||||||
|
for (DownloadLibraryJob s : t) {
|
||||||
|
if (names.contains(s.name))
|
||||||
|
continue;
|
||||||
|
names.add(s.name);
|
||||||
parallelTask.addDependsTask(new LibraryDownloadTask(s));
|
parallelTask.addDependsTask(new LibraryDownloadTask(s));
|
||||||
|
}
|
||||||
dw.append(parallelTask);
|
dw.append(parallelTask);
|
||||||
boolean flag = true;
|
boolean flag = true;
|
||||||
if (t.size() > 0)
|
if (t.size() > 0)
|
||||||
|
@ -99,9 +99,15 @@ public final class Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Profile getProfile(String name) {
|
public static Profile getProfile(String name) {
|
||||||
|
Profile p;
|
||||||
if (name == null)
|
if (name == null)
|
||||||
return getProfiles().get("Default");
|
p = getProfiles().get("Default");
|
||||||
return getProfiles().get(name);
|
else
|
||||||
|
p = getProfiles().get(name);
|
||||||
|
if (p == null)
|
||||||
|
if (!getProfiles().containsKey(DEFAULT_PROFILE))
|
||||||
|
getProfiles().put(DEFAULT_PROFILE, p = new Profile());
|
||||||
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Map<String, Profile> getProfiles() {
|
public static Map<String, Profile> getProfiles() {
|
||||||
@ -144,6 +150,8 @@ public final class Settings {
|
|||||||
|
|
||||||
static void onProfileChanged() {
|
static void onProfileChanged() {
|
||||||
Profile p = getLastProfile();
|
Profile p = getLastProfile();
|
||||||
|
if (p == null)
|
||||||
|
throw new Error("No profiles here, it should not happen");
|
||||||
profileChangedEvent.execute(p);
|
profileChangedEvent.execute(p);
|
||||||
p.onSelected();
|
p.onSelected();
|
||||||
}
|
}
|
||||||
|
@ -107,4 +107,8 @@ public class AnimatedPanel extends JPanel implements Selectable {
|
|||||||
public void onLeaving() {
|
public void onLeaving() {
|
||||||
selected = false;
|
selected = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreated() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1300,8 +1300,8 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelected() {
|
public void onCreated() {
|
||||||
super.onSelected();
|
super.onCreated();
|
||||||
Settings.onProfileLoading();
|
Settings.onProfileLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1387,6 +1387,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
private final javax.swing.JPanel pnlGameDownloads;
|
private final javax.swing.JPanel pnlGameDownloads;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
|
|
||||||
|
//<editor-fold defaultstate="collapesd" desc="Profiles & Versions Loading">
|
||||||
final Runnable onLoadingProfiles = this::loadProfiles;
|
final Runnable onLoadingProfiles = this::loadProfiles;
|
||||||
|
|
||||||
private void loadProfiles() {
|
private void loadProfiles() {
|
||||||
@ -1436,4 +1437,5 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
((DefaultComboBoxModel) cboProfiles.getModel()).setSelectedItem(t.getName());
|
||||||
txtGameDir.setText(t.getGameDir());
|
txtGameDir.setText(t.getGameDir());
|
||||||
};
|
};
|
||||||
|
//</editor-fold>
|
||||||
}
|
}
|
||||||
|
@ -275,6 +275,7 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
if (tabContent[i] == null) {
|
if (tabContent[i] == null) {
|
||||||
try {
|
try {
|
||||||
tabContent[i] = tabClasses.get(i).newInstance();
|
tabContent[i] = tabClasses.get(i).newInstance();
|
||||||
|
tabContent[i].onCreated();
|
||||||
} catch (Exception mustnothappen) {
|
} catch (Exception mustnothappen) {
|
||||||
throw new Error(mustnothappen);
|
throw new Error(mustnothappen);
|
||||||
}
|
}
|
||||||
|
@ -418,8 +418,8 @@ public class MainPagePanel extends AnimatedPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSelected() {
|
public void onCreated() {
|
||||||
super.onSelected();
|
super.onCreated();
|
||||||
Settings.onProfileLoading();
|
Settings.onProfileLoading();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ package org.jackhuang.hellominecraft.launcher.ui;
|
|||||||
*/
|
*/
|
||||||
public interface Selectable {
|
public interface Selectable {
|
||||||
|
|
||||||
|
void onCreated();
|
||||||
|
|
||||||
void onSelected();
|
void onSelected();
|
||||||
|
|
||||||
boolean isSelected();
|
boolean isSelected();
|
||||||
|
@ -48,7 +48,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
|||||||
wizardData.put(KEY_GAME_VERSION, versions);
|
wizardData.put(KEY_GAME_VERSION, versions);
|
||||||
|
|
||||||
configureComboContents();
|
configureComboContents();
|
||||||
controller.setProblem(C.i18n("modpack.not_a_valid_location"));
|
checkProblem();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureComboContents() {
|
private void configureComboContents() {
|
||||||
@ -170,10 +170,7 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
|||||||
private void txtModpackLocationCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtModpackLocationCaretUpdate
|
private void txtModpackLocationCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtModpackLocationCaretUpdate
|
||||||
wizardData.put(KEY_MODPACK_LOCATION, txtModpackLocation.getText());
|
wizardData.put(KEY_MODPACK_LOCATION, txtModpackLocation.getText());
|
||||||
|
|
||||||
if (txtModpackLocation.getText().trim().isEmpty())
|
checkProblem();
|
||||||
controller.setProblem(C.i18n("modpack.not_a_valid_location"));
|
|
||||||
else
|
|
||||||
controller.setProblem(null);
|
|
||||||
}//GEN-LAST:event_txtModpackLocationCaretUpdate
|
}//GEN-LAST:event_txtModpackLocationCaretUpdate
|
||||||
|
|
||||||
private void cboGameVersionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboGameVersionItemStateChanged
|
private void cboGameVersionItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboGameVersionItemStateChanged
|
||||||
@ -183,11 +180,16 @@ public class ModpackInitializationPanel extends javax.swing.JPanel {
|
|||||||
private void txtModpackNameCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtModpackNameCaretUpdate
|
private void txtModpackNameCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_txtModpackNameCaretUpdate
|
||||||
wizardData.put(KEY_MODPACK_NAME, txtModpackName.getText());
|
wizardData.put(KEY_MODPACK_NAME, txtModpackName.getText());
|
||||||
|
|
||||||
|
checkProblem();
|
||||||
|
}//GEN-LAST:event_txtModpackNameCaretUpdate
|
||||||
|
|
||||||
|
void checkProblem() {
|
||||||
|
controller.setProblem(null);
|
||||||
|
if (txtModpackLocation.getText().trim().isEmpty())
|
||||||
|
controller.setProblem(C.i18n("modpack.not_a_valid_location"));
|
||||||
if (txtModpackName.getText().trim().isEmpty())
|
if (txtModpackName.getText().trim().isEmpty())
|
||||||
controller.setProblem(C.i18n("modpack.not_a_valid_name"));
|
controller.setProblem(C.i18n("modpack.not_a_valid_name"));
|
||||||
else
|
}
|
||||||
controller.setProblem(null);
|
|
||||||
}//GEN-LAST:event_txtModpackNameCaretUpdate
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JComboBox<String> cboGameVersion;
|
private javax.swing.JComboBox<String> cboGameVersion;
|
||||||
|
@ -83,13 +83,15 @@ public class DefaultMinecraftService extends IMinecraftService {
|
|||||||
private void loadVersionSetting(String id) {
|
private void loadVersionSetting(String id) {
|
||||||
if (provider.getVersionById(id) == null)
|
if (provider.getVersionById(id) == null)
|
||||||
return;
|
return;
|
||||||
VersionSetting vs = new VersionSetting();
|
VersionSetting vs = null;
|
||||||
File f = new File(provider.versionRoot(id), "hmclversion.cfg");
|
File f = new File(provider.versionRoot(id), "hmclversion.cfg");
|
||||||
if (f.exists()) {
|
if (f.exists()) {
|
||||||
String s = FileUtils.readFileToStringQuietly(f);
|
String s = FileUtils.readFileToStringQuietly(f);
|
||||||
if (s != null)
|
if (s != null)
|
||||||
vs = C.GSON.fromJson(s, VersionSetting.class);
|
vs = C.GSON.fromJson(s, VersionSetting.class);
|
||||||
}
|
}
|
||||||
|
if (vs == null)
|
||||||
|
vs = new VersionSetting();
|
||||||
vs.id = id;
|
vs.id = id;
|
||||||
vs.propertyChanged.register((sender, t) -> {
|
vs.propertyChanged.register((sender, t) -> {
|
||||||
saveVersionSetting(((VersionSetting) sender).id);
|
saveVersionSetting(((VersionSetting) sender).id);
|
||||||
@ -98,6 +100,13 @@ public class DefaultMinecraftService extends IMinecraftService {
|
|||||||
versionSettings.put(id, vs);
|
versionSettings.put(id, vs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version setting for version id.
|
||||||
|
*
|
||||||
|
* @param id version id
|
||||||
|
*
|
||||||
|
* @return may return null if the id not exists
|
||||||
|
*/
|
||||||
public VersionSetting getVersionSetting(String id) {
|
public VersionSetting getVersionSetting(String id) {
|
||||||
if (!versionSettings.containsKey(id))
|
if (!versionSettings.containsKey(id))
|
||||||
loadVersionSetting(id);
|
loadVersionSetting(id);
|
||||||
|
@ -20,6 +20,7 @@ package org.jackhuang.hellominecraft.launcher.util;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
||||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersionManager;
|
||||||
|
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -33,8 +34,12 @@ public class HMCLGameProvider extends MinecraftVersionManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File getRunDirectory(String id) {
|
public File getRunDirectory(String id) {
|
||||||
return ((DefaultMinecraftService) service).getVersionSetting(id).getGameDirType() == GameDirType.VERSION_FOLDER
|
VersionSetting vs = ((DefaultMinecraftService) service).getVersionSetting(id);
|
||||||
? service.version().versionRoot(id)
|
if (vs == null)
|
||||||
: super.getRunDirectory(id);
|
return super.getRunDirectory(id);
|
||||||
|
else
|
||||||
|
return ((DefaultMinecraftService) service).getVersionSetting(id).getGameDirType() == GameDirType.VERSION_FOLDER
|
||||||
|
? service.version().versionRoot(id)
|
||||||
|
: super.getRunDirectory(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,24 @@ import org.jackhuang.hellominecraft.util.system.OS;
|
|||||||
*/
|
*/
|
||||||
public class AppDataUpgrader extends IUpgrader {
|
public class AppDataUpgrader extends IUpgrader {
|
||||||
|
|
||||||
|
private boolean launchNewerVersion(String[] args, File jar) throws Exception {
|
||||||
|
try (JarFile jarFile = new JarFile(jar)) {
|
||||||
|
String mainClass = jarFile.getManifest().getMainAttributes().getValue("Main-Class");
|
||||||
|
if (mainClass != null) {
|
||||||
|
ArrayList<String> al = new ArrayList<>(Arrays.asList(args));
|
||||||
|
al.add("nofound");
|
||||||
|
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
||||||
|
new URLClassLoader(new URL[] { jar.toURI().toURL() },
|
||||||
|
URLClassLoader.getSystemClassLoader().getParent()).loadClass(mainClass)
|
||||||
|
.getMethod("main", String[].class).invoke(null, new Object[] { al.toArray(new String[0]) });
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean parseArguments(VersionNumber nowVersion, String[] args) {
|
public boolean parseArguments(VersionNumber nowVersion, String[] args) {
|
||||||
if (!ArrayUtils.contains(args, "nofound"))
|
if (!ArrayUtils.contains(args, "nofound"))
|
||||||
@ -70,20 +88,7 @@ public class AppDataUpgrader extends IUpgrader {
|
|||||||
if (j != null) {
|
if (j != null) {
|
||||||
File jar = new File(j);
|
File jar = new File(j);
|
||||||
if (jar.exists())
|
if (jar.exists())
|
||||||
try (JarFile jarFile = new JarFile(jar)) {
|
return launchNewerVersion(args, jar);
|
||||||
String mainClass = jarFile.getManifest().getMainAttributes().getValue("Main-Class");
|
|
||||||
if (mainClass != null) {
|
|
||||||
ArrayList<String> al = new ArrayList<>(Arrays.asList(args));
|
|
||||||
al.add("notfound");
|
|
||||||
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
|
||||||
new URLClassLoader(new URL[] { jar.toURI().toURL() },
|
|
||||||
URLClassLoader.getSystemClassLoader().getParent()).loadClass(mainClass)
|
|
||||||
.getMethod("main", String[].class).invoke(null, new Object[] { al.toArray(new String[0]) });
|
|
||||||
return null;
|
|
||||||
});
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,7 +103,10 @@ public class AppDataUpgrader extends IUpgrader {
|
|||||||
((UpdateChecker) sender).requestDownloadLink().reg(map -> {
|
((UpdateChecker) sender).requestDownloadLink().reg(map -> {
|
||||||
if (map != null && map.containsKey("pack"))
|
if (map != null && map.containsKey("pack"))
|
||||||
try {
|
try {
|
||||||
if (TaskWindow.factory().append(new AppDataUpgraderTask(map.get("pack"), number.version)).create()) {
|
String hash = null;
|
||||||
|
if (map.containsKey("packsha1"))
|
||||||
|
hash = map.get("packsha1");
|
||||||
|
if (TaskWindow.factory().append(new AppDataUpgraderTask(map.get("pack"), number.version, hash)).create()) {
|
||||||
new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(number.version).getAbsolutePath() }).directory(new File(".")).start();
|
new ProcessBuilder(new String[] { IOUtils.getJavaDir(), "-jar", AppDataUpgraderTask.getSelf(number.version).getAbsolutePath() }).directory(new File(".")).start();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
@ -137,18 +145,19 @@ public class AppDataUpgrader extends IUpgrader {
|
|||||||
return new File(BASE_FOLDER, "HMCL-" + ver + ".jar");
|
return new File(BASE_FOLDER, "HMCL-" + ver + ".jar");
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String downloadLink, newestVersion;
|
private final String downloadLink, newestVersion, expectedHash;
|
||||||
File tempFile;
|
File tempFile;
|
||||||
|
|
||||||
public AppDataUpgraderTask(String downloadLink, String newestVersion) throws IOException {
|
public AppDataUpgraderTask(String downloadLink, String newestVersion, String hash) throws IOException {
|
||||||
this.downloadLink = downloadLink;
|
this.downloadLink = downloadLink;
|
||||||
this.newestVersion = newestVersion;
|
this.newestVersion = newestVersion;
|
||||||
tempFile = File.createTempFile("hmcl", ".pack.xz");
|
this.expectedHash = hash;
|
||||||
|
tempFile = File.createTempFile("hmcl", ".pack.gz");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Task> getDependTasks() {
|
public Collection<Task> getDependTasks() {
|
||||||
return Arrays.asList(new FileDownloadTask(downloadLink, tempFile));
|
return Arrays.asList(new FileDownloadTask(downloadLink, tempFile, expectedHash));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -169,7 +178,7 @@ public class AppDataUpgrader extends IUpgrader {
|
|||||||
json.put("ver", newestVersion);
|
json.put("ver", newestVersion);
|
||||||
json.put("loc", f.getAbsolutePath());
|
json.put("loc", f.getAbsolutePath());
|
||||||
String result = C.GSON.toJson(json);
|
String result = C.GSON.toJson(json);
|
||||||
FileUtils.write(HMCL_VER_FILE, result);
|
FileUtils.writeStringToFile(HMCL_VER_FILE, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,7 +44,6 @@ public final class UpdateChecker implements IUpdateChecker {
|
|||||||
return new OverridableSwingWorker() {
|
return new OverridableSwingWorker() {
|
||||||
@Override
|
@Override
|
||||||
protected void work() throws Exception {
|
protected void work() throws Exception {
|
||||||
|
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
versionString = NetUtils.get("http://huangyuhui.duapp.com/info.php?type=" + type);
|
versionString = NetUtils.get("http://huangyuhui.duapp.com/info.php?type=" + type);
|
||||||
value = VersionNumber.check(versionString);
|
value = VersionNumber.check(versionString);
|
||||||
|
@ -177,6 +177,8 @@ public class FileDownloadTask extends Task implements PreviousResult<File>, Prev
|
|||||||
lastTime = now;
|
lastTime = now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (downloaded != contentLength)
|
||||||
|
throw new IllegalStateException("Unexptected file size: " + downloaded + ", expected: " + contentLength);
|
||||||
closeFiles();
|
closeFiles();
|
||||||
if (aborted)
|
if (aborted)
|
||||||
tempFile.delete();
|
tempFile.delete();
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
import java.util.jar.JarFile
|
import java.util.jar.JarFile
|
||||||
import java.util.jar.Pack200
|
import java.util.jar.Pack200
|
||||||
import java.util.zip.GZIPOutputStream
|
import java.util.zip.GZIPOutputStream
|
||||||
|
import java.security.MessageDigest
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
@ -94,6 +96,15 @@ task makePackGZ(dependsOn: jar) << {
|
|||||||
}
|
}
|
||||||
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz")
|
def loc = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".pack.gz")
|
||||||
def os = new GZIPOutputStream(new FileOutputStream(loc))
|
def os = new GZIPOutputStream(new FileOutputStream(loc))
|
||||||
Pack200.newPacker().pack(new JarFile(makeExecutableinjar), os)
|
Pack200.newPacker().pack new JarFile(makeExecutableinjar), os
|
||||||
os.close()
|
os.close()
|
||||||
}
|
|
||||||
|
def messageDigest = MessageDigest.getInstance("SHA1")
|
||||||
|
loc.eachByte 1024 * 1024, { byte[] buf, int bytesRead ->
|
||||||
|
messageDigest.update(buf, 0, bytesRead);
|
||||||
|
}
|
||||||
|
def sha1Hex = new BigInteger(1, messageDigest.digest()).toString(16).padLeft(40, '0')
|
||||||
|
def fileEx = new File(project.buildDir, "libs/" + makeExecutableoutjar.getName().substring(0, makeExecutableoutjar.getName().length()-4)+".sha1")
|
||||||
|
if (!fileEx.exists()) fileEx.createNewFile()
|
||||||
|
fileEx.append sha1Hex
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user