LauncherBuildTask введение новой системы сборки лаунчера

Часть 2
This commit is contained in:
Gravit 2019-01-05 22:28:25 +07:00
parent 4e1f268d4f
commit 18020a78d3
No known key found for this signature in database
GPG key ID: 061981E1E85D3216
5 changed files with 25 additions and 2 deletions

View file

@ -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

View file

@ -7,4 +7,5 @@ public interface LauncherBuildTask {
String getName();
int priority();
Path process(Path inputFile) throws IOException;
boolean allowDelete();
}

View file

@ -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);

View file

@ -36,4 +36,9 @@ public Path process(Path inputFile) throws IOException {
}
return server.proguardConf.outputJar;
}
@Override
public boolean allowDelete() {
return true;
}
}

View file

@ -27,4 +27,9 @@ public Path process(Path inputFile) throws IOException {
UnpackHelper.unpack(url, result);
return result;
}
@Override
public boolean allowDelete() {
return false;
}
}