LauncherBuildTask введение новой системы сборки лаунчера

Часть 3
This commit is contained in:
Gravit 2019-01-05 22:43:05 +07:00
parent 18020a78d3
commit 9e0c94581c
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
6 changed files with 15 additions and 23 deletions

View file

@ -135,6 +135,7 @@ public static final class Config {
public boolean isDownloadJava; public boolean isDownloadJava;
public boolean isWarningMissArchJava; public boolean isWarningMissArchJava;
public boolean enabledProGuard;
public String startScript; public String startScript;
@ -570,6 +571,7 @@ private void generateConfigIfNotExists() throws IOException {
newConfig.whitelistRejectString = "Вас нет в белом списке"; newConfig.whitelistRejectString = "Вас нет в белом списке";
newConfig.threadCoreCount = 0; // on your own newConfig.threadCoreCount = 0; // on your own
newConfig.enabledProGuard = true;
newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors(); newConfig.threadCount = JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() >= 4 ? JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors() / 2 : JVMHelper.OPERATING_SYSTEM_MXBEAN.getAvailableProcessors();
// Set server address // Set server address

View file

@ -53,7 +53,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
tasks = new ArrayList<>(); tasks = new ArrayList<>();
tasks.add(new UnpackBuildTask()); tasks.add(new UnpackBuildTask());
tasks.add(new MainBuildTask()); tasks.add(new MainBuildTask());
tasks.add(new ProGuardBuildTask()); if(server.config.enabledProGuard) tasks.add(new ProGuardBuildTask());
syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar"); syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar");
/*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); /*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
guardDir = server.dir.resolve(Launcher.GUARD_DIR); guardDir = server.dir.resolve(Launcher.GUARD_DIR);
@ -73,17 +73,23 @@ public void build() throws IOException {
LogHelper.info("Building launcher binary file"); LogHelper.info("Building launcher binary file");
Path thisPath = null; Path thisPath = null;
boolean isNeedDelete = false; boolean isNeedDelete = false;
long time_start = System.currentTimeMillis();
long time_this = time_start;
for(LauncherBuildTask task : tasks) for(LauncherBuildTask task : tasks)
{ {
LogHelper.subInfo("Task %s",task.getName()); LogHelper.subInfo("Task %s",task.getName());
Path oldPath = thisPath; Path oldPath = thisPath;
thisPath = task.process(oldPath); thisPath = task.process(oldPath);
long time_task_end = System.currentTimeMillis();
long time_task = time_task_end - time_this;
time_this = time_task_end;
if(isNeedDelete) Files.delete(oldPath); if(isNeedDelete) Files.delete(oldPath);
isNeedDelete = task.allowDelete(); isNeedDelete = task.allowDelete();
LogHelper.subInfo("Task %s processed",task.getName()); LogHelper.subInfo("Task %s processed from %d millis",task.getName(), time_task);
} }
long time_end = System.currentTimeMillis();
IOHelper.move(thisPath, syncBinaryFile); IOHelper.move(thisPath, syncBinaryFile);
LogHelper.info("Build successful"); LogHelper.info("Build successful from %d millis",time_end - time_start);
// ProGuard // ProGuard

View file

@ -5,7 +5,6 @@
public interface LauncherBuildTask { public interface LauncherBuildTask {
String getName(); String getName();
int priority();
Path process(Path inputFile) throws IOException; Path process(Path inputFile) throws IOException;
boolean allowDelete(); boolean allowDelete();
} }

View file

@ -109,17 +109,12 @@ private static ZipEntry newGuardEntry(String fileName) {
public MainBuildTask() { public MainBuildTask() {
runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR); runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
guardDir = server.dir.resolve(Launcher.GUARD_DIR); guardDir = server.dir.resolve(Launcher.GUARD_DIR);
binaryFile = server.dir.resolve(server.config.binaryName + "-main_task.jar"); binaryFile = server.dir.resolve(server.config.binaryName + "-main.jar");
} }
@Override @Override
public String getName() { public String getName() {
return "main"; return "MainBuild";
}
@Override
public int priority() {
return 0;
} }
@Override @Override

View file

@ -13,12 +13,7 @@ public class ProGuardBuildTask implements LauncherBuildTask {
public static LaunchServer server = LaunchServer.server; public static LaunchServer server = LaunchServer.server;
@Override @Override
public String getName() { public String getName() {
return "proguard"; return "ProGuard";
}
@Override
public int priority() {
return 1;
} }
@Override @Override

View file

@ -12,12 +12,7 @@ public class UnpackBuildTask implements LauncherBuildTask {
public static LaunchServer server = LaunchServer.server; public static LaunchServer server = LaunchServer.server;
@Override @Override
public String getName() { public String getName() {
return "unpack clean"; return "UnpackFromResources";
}
@Override
public int priority() {
return -1;
} }
@Override @Override