mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-31 20:59:54 +03:00
LauncherBuildTask введение новой системы сборки лаунчера
Часть 2
This commit is contained in:
parent
4e1f268d4f
commit
18020a78d3
5 changed files with 25 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
@ -53,6 +54,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
|||
tasks.add(new UnpackBuildTask());
|
||||
tasks.add(new MainBuildTask());
|
||||
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);
|
||||
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
|
||||
|
@ -70,13 +72,17 @@ public void build() throws IOException {
|
|||
// Build launcher binary
|
||||
LogHelper.info("Building launcher binary file");
|
||||
Path thisPath = null;
|
||||
boolean isNeedDelete = false;
|
||||
for(LauncherBuildTask task : tasks)
|
||||
{
|
||||
LogHelper.subInfo("Task %s",task.getName());
|
||||
thisPath = task.process(thisPath);
|
||||
Path oldPath = thisPath;
|
||||
thisPath = task.process(oldPath);
|
||||
if(isNeedDelete) Files.delete(oldPath);
|
||||
isNeedDelete = task.allowDelete();
|
||||
LogHelper.subInfo("Task %s processed",task.getName());
|
||||
}
|
||||
syncBinaryFile = thisPath;
|
||||
IOHelper.move(thisPath, syncBinaryFile);
|
||||
LogHelper.info("Build successful");
|
||||
|
||||
// ProGuard
|
||||
|
|
|
@ -7,4 +7,5 @@ public interface LauncherBuildTask {
|
|||
String getName();
|
||||
int priority();
|
||||
Path process(Path inputFile) throws IOException;
|
||||
boolean allowDelete();
|
||||
}
|
||||
|
|
|
@ -207,6 +207,12 @@ public Path process(Path cleanJar) throws IOException {
|
|||
}
|
||||
return binaryFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowDelete() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void tryUnpack() throws IOException {
|
||||
LogHelper.info("Unpacking launcher native guard files and runtime");
|
||||
UnpackHelper.unpackZipNoCheck("guard.zip", guardDir);
|
||||
|
|
|
@ -36,4 +36,9 @@ public Path process(Path inputFile) throws IOException {
|
|||
}
|
||||
return server.proguardConf.outputJar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowDelete() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,4 +27,9 @@ public Path process(Path inputFile) throws IOException {
|
|||
UnpackHelper.unpack(url, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowDelete() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue