From 9e0c94581c9da40313585f61307e855e11f81f95 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 5 Jan 2019 22:43:05 +0700 Subject: [PATCH] =?UTF-8?q?LauncherBuildTask=20=D0=B2=D0=B2=D0=B5=D0=B4?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20?= =?UTF-8?q?=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B=20=D1=81=D0=B1=D0=BE?= =?UTF-8?q?=D1=80=D0=BA=D0=B8=20=D0=BB=D0=B0=D1=83=D0=BD=D1=87=D0=B5=D1=80?= =?UTF-8?q?=D0=B0=20=D0=A7=D0=B0=D1=81=D1=82=D1=8C=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/LaunchServer.java | 2 ++ .../launchserver/binary/JARLauncherBinary.java | 12 +++++++++--- .../launchserver/binary/tasks/LauncherBuildTask.java | 1 - .../launchserver/binary/tasks/MainBuildTask.java | 9 ++------- .../launchserver/binary/tasks/ProGuardBuildTask.java | 7 +------ .../launchserver/binary/tasks/UnpackBuildTask.java | 7 +------ 6 files changed, 15 insertions(+), 23 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 3742ecd3..fc50a453 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -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 diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java index 80b2576c..93adb743 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/JARLauncherBinary.java @@ -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 diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/LauncherBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/LauncherBuildTask.java index d8d5a9ad..59d337ce 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/LauncherBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/LauncherBuildTask.java @@ -5,7 +5,6 @@ public interface LauncherBuildTask { String getName(); - int priority(); Path process(Path inputFile) throws IOException; boolean allowDelete(); } diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java index 5636b6df..4389c636 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -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 diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java index c3f9dd7c..73ebd9c3 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/ProGuardBuildTask.java @@ -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 diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java index 8b845e05..95242ede 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/UnpackBuildTask.java @@ -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