From a2784aaa459e55b99180c66d5e62d83cca8e316a Mon Sep 17 00:00:00 2001 From: zaxar163 Date: Wed, 13 Mar 2019 21:46:08 +0300 Subject: [PATCH] [FEATURE] RadonBuildTask. TODO: Integrate it and create default config. --- .../launchserver/binary/ProguardConf.java | 5 +- .../binary/tasks/RadonBuildTask.java | 47 +++++++++++++++++++ .../ru/gravit/launchserver/defaults/radon.cfg | 0 3 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java create mode 100644 LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java index 6853ee48..389fa0a5 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/ProguardConf.java @@ -4,6 +4,7 @@ import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.SecurityHelper; +import ru.gravit.utils.helper.UnpackHelper; import java.io.*; import java.nio.file.Files; @@ -58,9 +59,7 @@ public String[] buildConfig(Path inputJar, Path outputJar) { private void genConfig(boolean force) throws IOException { if (IOHelper.exists(config) && !force) return; Files.deleteIfExists(config); - try (OutputStream out = IOHelper.newOutput(config); InputStream in = IOHelper.newInput(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"))) { - IOHelper.transfer(in, out); - } + UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/proguard.cfg"), config); } public void genWords(boolean force) throws IOException { diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java new file mode 100644 index 00000000..505ed17f --- /dev/null +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/binary/tasks/RadonBuildTask.java @@ -0,0 +1,47 @@ +package ru.gravit.launchserver.binary.tasks; + +import ru.gravit.launchserver.LaunchServer; +import ru.gravit.utils.helper.IOHelper; +import ru.gravit.utils.helper.UnpackHelper; + +import java.io.IOException; +import java.nio.file.Path; +import java.util.stream.Collectors; + +import me.itzsomebody.radon.Radon; +import me.itzsomebody.radon.SessionInfo; +import me.itzsomebody.radon.config.ConfigurationParser; + +public class RadonBuildTask implements LauncherBuildTask { + private final LaunchServer srv; + public final Path config; + + public RadonBuildTask(LaunchServer srv) { + this.srv = srv; + config = this.srv.dir.resolve("radon.yml"); + } + + @Override + public String getName() { + return "Radon"; + } + + @Override + public Path process(Path inputFile) throws IOException { + if (!IOHelper.isFile(config)) UnpackHelper.unpack(IOHelper.getResourceURL("ru/gravit/launchserver/defaults/radon.cfg"), config); + Path outputFile = srv.launcherBinary.nextLowerPath(this); + ConfigurationParser p = new ConfigurationParser(IOHelper.newInput(config)); + SessionInfo info = p.createSessionFromConfig(); + info.setInput(inputFile.toFile()); + info.setOutput(outputFile.toFile()); + info.setLibraries(srv.launcherBinary.coreLibs.stream().map(e -> e.toFile()).collect(Collectors.toList())); + Radon r = new Radon(info); + r.run(); + return outputFile; + } + + @Override + public boolean allowDelete() { + return true; + } +} diff --git a/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg b/LaunchServer/src/main/resources/ru/gravit/launchserver/defaults/radon.cfg new file mode 100644 index 00000000..e69de29b