mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] FxRuntimeOptimizerModule
This commit is contained in:
parent
ead4689bcf
commit
f484f045ca
4 changed files with 29 additions and 10 deletions
|
@ -46,11 +46,14 @@ public class BuildContext {
|
||||||
public final HashSet<String> fileList;
|
public final HashSet<String> fileList;
|
||||||
public final HashSet<String> clientModules;
|
public final HashSet<String> clientModules;
|
||||||
public final HashSet<String> legacyClientModules;
|
public final HashSet<String> legacyClientModules;
|
||||||
|
private Path runtimeDir;
|
||||||
|
private boolean deleteRuntimeDir;
|
||||||
|
|
||||||
public BuildContext(ZipOutputStream output, List<JarFile> readerClassPath, MainBuildTask task) {
|
public BuildContext(ZipOutputStream output, List<JarFile> readerClassPath, MainBuildTask task, Path runtimeDir) {
|
||||||
this.output = output;
|
this.output = output;
|
||||||
this.readerClassPath = readerClassPath;
|
this.readerClassPath = readerClassPath;
|
||||||
this.task = task;
|
this.task = task;
|
||||||
|
this.runtimeDir = runtimeDir;
|
||||||
fileList = new HashSet<>(1024);
|
fileList = new HashSet<>(1024);
|
||||||
clientModules = new HashSet<>();
|
clientModules = new HashSet<>();
|
||||||
legacyClientModules = new HashSet<>();
|
legacyClientModules = new HashSet<>();
|
||||||
|
@ -103,6 +106,14 @@ public void pushJarFile(Path jarfile, Predicate<ZipEntry> filter, Predicate<Stri
|
||||||
pushJarFile(jarfile.toUri().toURL(), filter, needTransform);
|
pushJarFile(jarfile.toUri().toURL(), filter, needTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Path getRuntimeDir() {
|
||||||
|
return runtimeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuntimeDir(Path runtimeDir) {
|
||||||
|
this.runtimeDir = runtimeDir;
|
||||||
|
}
|
||||||
|
|
||||||
public void pushJarFile(URL jarfile, Predicate<ZipEntry> filter, Predicate<String> needTransform) throws IOException {
|
public void pushJarFile(URL jarfile, Predicate<ZipEntry> filter, Predicate<String> needTransform) throws IOException {
|
||||||
try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(jarfile))) {
|
try (ZipInputStream input = new ZipInputStream(IOHelper.newInput(jarfile))) {
|
||||||
ZipEntry e = input.getNextEntry();
|
ZipEntry e = input.getNextEntry();
|
||||||
|
@ -129,6 +140,16 @@ public void pushJarFile(URL jarfile, Predicate<ZipEntry> filter, Predicate<Strin
|
||||||
e = input.getNextEntry();
|
e = input.getNextEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDeleteRuntimeDir() {
|
||||||
|
return deleteRuntimeDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeleteRuntimeDir(boolean deleteRuntimeDir) {
|
||||||
|
this.deleteRuntimeDir = deleteRuntimeDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
private final static class RuntimeDirVisitor extends SimpleFileVisitor<Path> {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public String getName() {
|
||||||
public Path process(Path inputJar) throws IOException {
|
public Path process(Path inputJar) throws IOException {
|
||||||
Path outputJar = server.launcherBinary.nextPath(this);
|
Path outputJar = server.launcherBinary.nextPath(this);
|
||||||
try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(outputJar))) {
|
try (ZipOutputStream output = new ZipOutputStream(IOHelper.newOutput(outputJar))) {
|
||||||
BuildContext context = new BuildContext(output, reader.getCp(), this);
|
BuildContext context = new BuildContext(output, reader.getCp(), this, server.launcherBinary.runtimeDir);
|
||||||
initProps();
|
initProps();
|
||||||
preBuildHook.hook(context);
|
preBuildHook.hook(context);
|
||||||
properties.put("launcher.legacymodules", context.legacyClientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
properties.put("launcher.legacymodules", context.legacyClientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
||||||
|
@ -69,9 +69,12 @@ public Path process(Path inputJar) throws IOException {
|
||||||
Map<String, byte[]> runtime = new HashMap<>(256);
|
Map<String, byte[]> runtime = new HashMap<>(256);
|
||||||
// Write launcher guard dir
|
// Write launcher guard dir
|
||||||
if (server.config.launcher.encryptRuntime) {
|
if (server.config.launcher.encryptRuntime) {
|
||||||
context.pushEncryptedDir(server.launcherBinary.runtimeDir, Launcher.RUNTIME_DIR, server.runtime.runtimeEncryptKey, runtime, false);
|
context.pushEncryptedDir(context.getRuntimeDir(), Launcher.RUNTIME_DIR, server.runtime.runtimeEncryptKey, runtime, false);
|
||||||
} else {
|
} else {
|
||||||
context.pushDir(server.launcherBinary.runtimeDir, Launcher.RUNTIME_DIR, runtime, false);
|
context.pushDir(context.getRuntimeDir(), Launcher.RUNTIME_DIR, runtime, false);
|
||||||
|
}
|
||||||
|
if(context.isDeleteRuntimeDir()) {
|
||||||
|
IOHelper.deleteDir(context.getRuntimeDir(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
LauncherConfig launcherConfig = new LauncherConfig(server.config.netty.address, server.keyAgreementManager.ecdsaPublicKey, server.keyAgreementManager.rsaPublicKey, runtime, server.config.projectName);
|
LauncherConfig launcherConfig = new LauncherConfig(server.config.netty.address, server.keyAgreementManager.ecdsaPublicKey, server.keyAgreementManager.rsaPublicKey, runtime, server.config.projectName);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
apply plugin: 'org.openjfx.javafxplugin'
|
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
|
||||||
String mainClassName = "pro.gravit.launcher.start.ClientLauncherWrapper"
|
String mainClassName = "pro.gravit.launcher.start.ClientLauncherWrapper"
|
||||||
|
@ -9,10 +8,6 @@
|
||||||
url "https://repo.spring.io/plugins-release/"
|
url "https://repo.spring.io/plugins-release/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
javafx {
|
|
||||||
version = "12"
|
|
||||||
modules = ['javafx.controls', 'javafx.fxml']
|
|
||||||
}
|
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '17'
|
||||||
targetCompatibility = '17'
|
targetCompatibility = '17'
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
|
id 'com.github.johnrengelman.shadow' version '7.1.2' apply false
|
||||||
id 'maven-publish'
|
id 'maven-publish'
|
||||||
id 'signing'
|
id 'signing'
|
||||||
id 'org.openjfx.javafxplugin' version '0.0.10' apply false
|
id 'org.openjfx.javafxplugin' version '0.1.0' apply false
|
||||||
}
|
}
|
||||||
group = 'pro.gravit.launcher'
|
group = 'pro.gravit.launcher'
|
||||||
version = '5.6.0-SNAPSHOT'
|
version = '5.6.0-SNAPSHOT'
|
||||||
|
|
Loading…
Reference in a new issue