mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-03 22:30:31 +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.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.SimpleFileVisitor;
|
import java.nio.file.SimpleFileVisitor;
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
@ -53,6 +54,7 @@ public JARLauncherBinary(LaunchServer server) throws IOException {
|
||||||
tasks.add(new UnpackBuildTask());
|
tasks.add(new UnpackBuildTask());
|
||||||
tasks.add(new MainBuildTask());
|
tasks.add(new MainBuildTask());
|
||||||
tasks.add(new ProGuardBuildTask());
|
tasks.add(new ProGuardBuildTask());
|
||||||
|
syncBinaryFile = server.dir.resolve(server.config.binaryName + ".jar");
|
||||||
/*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
/*runtimeDir = server.dir.resolve(Launcher.RUNTIME_DIR);
|
||||||
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
guardDir = server.dir.resolve(Launcher.GUARD_DIR);
|
||||||
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
|
initScriptFile = runtimeDir.resolve(Launcher.INIT_SCRIPT_FILE);
|
||||||
|
@ -70,13 +72,17 @@ public void build() throws IOException {
|
||||||
// Build launcher binary
|
// Build launcher binary
|
||||||
LogHelper.info("Building launcher binary file");
|
LogHelper.info("Building launcher binary file");
|
||||||
Path thisPath = null;
|
Path thisPath = null;
|
||||||
|
boolean isNeedDelete = false;
|
||||||
for(LauncherBuildTask task : tasks)
|
for(LauncherBuildTask task : tasks)
|
||||||
{
|
{
|
||||||
LogHelper.subInfo("Task %s",task.getName());
|
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());
|
LogHelper.subInfo("Task %s processed",task.getName());
|
||||||
}
|
}
|
||||||
syncBinaryFile = thisPath;
|
IOHelper.move(thisPath, syncBinaryFile);
|
||||||
LogHelper.info("Build successful");
|
LogHelper.info("Build successful");
|
||||||
|
|
||||||
// ProGuard
|
// ProGuard
|
||||||
|
|
|
@ -7,4 +7,5 @@ public interface LauncherBuildTask {
|
||||||
String getName();
|
String getName();
|
||||||
int priority();
|
int priority();
|
||||||
Path process(Path inputFile) throws IOException;
|
Path process(Path inputFile) throws IOException;
|
||||||
|
boolean allowDelete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,12 @@ public Path process(Path cleanJar) throws IOException {
|
||||||
}
|
}
|
||||||
return binaryFile;
|
return binaryFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowDelete() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public void tryUnpack() throws IOException {
|
public void tryUnpack() throws IOException {
|
||||||
LogHelper.info("Unpacking launcher native guard files and runtime");
|
LogHelper.info("Unpacking launcher native guard files and runtime");
|
||||||
UnpackHelper.unpackZipNoCheck("guard.zip", guardDir);
|
UnpackHelper.unpackZipNoCheck("guard.zip", guardDir);
|
||||||
|
|
|
@ -36,4 +36,9 @@ public Path process(Path inputFile) throws IOException {
|
||||||
}
|
}
|
||||||
return server.proguardConf.outputJar;
|
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);
|
UnpackHelper.unpack(url, result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowDelete() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue