mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
LauncherBuildTask введение новой системы сборки лаунчера
Часть 3
This commit is contained in:
parent
18020a78d3
commit
9e0c94581c
6 changed files with 15 additions and 23 deletions
|
@ -135,6 +135,7 @@ public static final class Config {
|
|||
public boolean isDownloadJava;
|
||||
|
||||
public boolean isWarningMissArchJava;
|
||||
public boolean enabledProGuard;
|
||||
|
||||
public String startScript;
|
||||
|
||||
|
@ -570,6 +571,7 @@ private void generateConfigIfNotExists() throws IOException {
|
|||
newConfig.whitelistRejectString = "Вас нет в белом списке";
|
||||
|
||||
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();
|
||||
|
||||
// Set server address
|
||||
|
|
|
@ -53,7 +53,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
|||
tasks = new ArrayList<>();
|
||||
tasks.add(new UnpackBuildTask());
|
||||
tasks.add(new MainBuildTask());
|
||||
tasks.add(new ProGuardBuildTask());
|
||||
if(server.config.enabledProGuard) tasks.add(new ProGuardBuildTask());
|
||||
syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar");
|
||||
/*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
||||
|
@ -73,17 +73,23 @@ public void build() throws IOException {
|
|||
LogHelper.info("Building launcher binary file");
|
||||
Path thisPath = null;
|
||||
boolean isNeedDelete = false;
|
||||
long time_start = System.currentTimeMillis();
|
||||
long time_this = time_start;
|
||||
for(LauncherBuildTask task : tasks)
|
||||
{
|
||||
LogHelper.subInfo("Task %s",task.getName());
|
||||
Path oldPath = thisPath;
|
||||
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);
|
||||
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);
|
||||
LogHelper.info("Build successful");
|
||||
LogHelper.info("Build successful from %d millis",time_end - time_start);
|
||||
|
||||
// ProGuard
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
public interface LauncherBuildTask {
|
||||
String getName();
|
||||
int priority();
|
||||
Path process(Path inputFile) throws IOException;
|
||||
boolean allowDelete();
|
||||
}
|
||||
|
|
|
@ -109,17 +109,12 @@ private static ZipEntry newGuardEntry(String fileName) {
|
|||
public MainBuildTask() {
|
||||
runtimeDir = server.dir.resolve(Launcher.RUNTIME_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
|
||||
public String getName() {
|
||||
return "main";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return 0;
|
||||
return "MainBuild";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,12 +13,7 @@ public class ProGuardBuildTask implements LauncherBuildTask {
|
|||
public static LaunchServer server = LaunchServer.server;
|
||||
@Override
|
||||
public String getName() {
|
||||
return "proguard";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return 1;
|
||||
return "ProGuard";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -12,12 +12,7 @@ public class UnpackBuildTask implements LauncherBuildTask {
|
|||
public static LaunchServer server = LaunchServer.server;
|
||||
@Override
|
||||
public String getName() {
|
||||
return "unpack clean";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int priority() {
|
||||
return -1;
|
||||
return "UnpackFromResources";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue