mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] RadonBuildTask. TODO: Integrate it and create default config.
This commit is contained in:
parent
e0eb90ec37
commit
a2784aaa45
3 changed files with 49 additions and 3 deletions
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue