[FEATURE] LwjglDownloadCommand, modules and modulePath

This commit is contained in:
Gravita 2022-03-22 15:36:26 +07:00
parent e0f291fdac
commit 6663f38241
4 changed files with 45 additions and 9 deletions

View file

@ -20,6 +20,7 @@
import pro.gravit.utils.Version; import pro.gravit.utils.Version;
import pro.gravit.utils.helper.*; import pro.gravit.utils.helper.*;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
@ -33,7 +34,7 @@ public class ClientLauncherProcess {
public final ClientParams params = new ClientParams(); public final ClientParams params = new ClientParams();
public final List<String> jvmArgs = new LinkedList<>(); public final List<String> jvmArgs = new LinkedList<>();
public final List<String> jvmModules = new LinkedList<>(); public final List<String> jvmModules = new LinkedList<>();
public final List<Path> jvmModulesPaths = new LinkedList<>(); public final List<String> jvmModulesPaths = new LinkedList<>();
public final List<String> systemClientArgs = new LinkedList<>(); public final List<String> systemClientArgs = new LinkedList<>();
public final List<String> systemClassPath = new LinkedList<>(); public final List<String> systemClassPath = new LinkedList<>();
public final Map<String, String> systemEnv = new HashMap<>(); public final Map<String, String> systemEnv = new HashMap<>();
@ -127,7 +128,8 @@ private void applyClientProfile() {
this.params.oauthExpiredTime = Request.getTokenExpiredTime(); this.params.oauthExpiredTime = Request.getTokenExpiredTime();
this.params.extendedTokens = Request.getExtendedTokens(); this.params.extendedTokens = Request.getExtendedTokens();
} }
this.jvmModules.addAll(this.params.profile.getModules());
this.jvmModulesPaths.addAll(this.params.profile.getModulePath());
if (this.params.profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) { if (this.params.profile.getRuntimeInClientConfig() != ClientProfile.RuntimeInClientConfig.NONE) {
jvmModules.add("javafx.base"); jvmModules.add("javafx.base");
jvmModules.add("javafx.graphics"); jvmModules.add("javafx.graphics");
@ -137,6 +139,7 @@ private void applyClientProfile() {
jvmModules.add("javafx.media"); jvmModules.add("javafx.media");
jvmModules.add("javafx.web"); jvmModules.add("javafx.web");
} }
LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderCreateEvent(this)); LauncherEngine.modulesManager.invokeEvent(new ClientProcessBuilderCreateEvent(this));
} }
@ -187,20 +190,26 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException {
} }
private void applyJava9Params(List<String> processArgs) { private void applyJava9Params(List<String> processArgs) {
jvmModulesPaths.add(javaVersion.jvmDir); /*jvmModulesPaths.add(javaVersion.jvmDir);
jvmModulesPaths.add(javaVersion.jvmDir.resolve("jre")); jvmModulesPaths.add(javaVersion.jvmDir.resolve("jre"));
Path openjfxPath = JavaHelper.tryGetOpenJFXPath(javaVersion.jvmDir); Path openjfxPath = JavaHelper.tryGetOpenJFXPath(javaVersion.jvmDir);
if (openjfxPath != null) { if (openjfxPath != null) {
jvmModulesPaths.add(openjfxPath); jvmModulesPaths.add(openjfxPath);
} }*/ // TODO: fix runtime in client
StringBuilder modulesPath = new StringBuilder(); StringBuilder modulesPath = new StringBuilder();
StringBuilder modulesAdd = new StringBuilder(); StringBuilder modulesAdd = new StringBuilder();
for (String moduleName : jvmModules) { for (String moduleName : jvmModules) {
boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath); /*boolean success = JavaHelper.tryAddModule(jvmModulesPaths, moduleName, modulesPath);
if (success) { if (success) {
if (modulesAdd.length() > 0) modulesAdd.append(","); if (modulesAdd.length() > 0) modulesAdd.append(",");
modulesAdd.append(moduleName); modulesAdd.append(moduleName);
} }*/
if (modulesAdd.length() > 0) modulesAdd.append(",");
modulesAdd.append(moduleName);
}
for(String modulePath : jvmModulesPaths) {
if (modulesPath.length() > 0) modulesPath.append(File.pathSeparator);
modulesPath.append(modulePath);
} }
if (modulesAdd.length() > 0) { if (modulesAdd.length() > 0) {
processArgs.add("--add-modules"); processArgs.add("--add-modules");

View file

@ -48,6 +48,10 @@ public final class ClientProfile implements Comparable<ClientProfile> {
@LauncherNetworkAPI @LauncherNetworkAPI
private List<String> classPath; private List<String> classPath;
@LauncherNetworkAPI @LauncherNetworkAPI
private List<String> modulePath;
@LauncherNetworkAPI
private List<String> modules;
@LauncherNetworkAPI
private List<String> altClassPath; private List<String> altClassPath;
@LauncherNetworkAPI @LauncherNetworkAPI
private List<String> clientArgs; private List<String> clientArgs;
@ -91,6 +95,7 @@ public ClientProfile() {
updateOptional = new HashSet<>(); updateOptional = new HashSet<>();
jvmArgs = new ArrayList<>(); jvmArgs = new ArrayList<>();
classPath = new ArrayList<>(); classPath = new ArrayList<>();
modulePath = new ArrayList<>();
altClassPath = new ArrayList<>(); altClassPath = new ArrayList<>();
clientArgs = new ArrayList<>(); clientArgs = new ArrayList<>();
compatClasses = new ArrayList<>(); compatClasses = new ArrayList<>();
@ -102,7 +107,7 @@ public ClientProfile() {
runtimeInClientConfig = RuntimeInClientConfig.NONE; runtimeInClientConfig = RuntimeInClientConfig.NONE;
} }
public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateShared, List<String> updateVerify, Set<OptionalFile> updateOptional, List<String> jvmArgs, List<String> classPath, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) { public ClientProfile(List<String> update, List<String> updateExclusions, List<String> updateShared, List<String> updateVerify, Set<OptionalFile> updateOptional, List<String> jvmArgs, List<String> classPath, List<String> modulePath, List<String> modules, List<String> altClassPath, List<String> clientArgs, List<String> compatClasses, Map<String, String> properties, List<ServerProfile> servers, SecurityManagerConfig securityManagerConfig, ClassLoaderConfig classLoaderConfig, SignedClientConfig signedClientConfig, RuntimeInClientConfig runtimeInClientConfig, String version, String assetIndex, String dir, String assetDir, int recommendJavaVersion, int minJavaVersion, int maxJavaVersion, boolean warnMissJavaVersion, ProfileDefaultSettings settings, int sortIndex, UUID uuid, String title, String info, boolean updateFastCheck, String mainClass) {
this.update = update; this.update = update;
this.updateExclusions = updateExclusions; this.updateExclusions = updateExclusions;
this.updateShared = updateShared; this.updateShared = updateShared;
@ -110,6 +115,8 @@ public ClientProfile(List<String> update, List<String> updateExclusions, List<St
this.updateOptional = updateOptional; this.updateOptional = updateOptional;
this.jvmArgs = jvmArgs; this.jvmArgs = jvmArgs;
this.classPath = classPath; this.classPath = classPath;
this.modulePath = modulePath;
this.modules = modules;
this.altClassPath = altClassPath; this.altClassPath = altClassPath;
this.clientArgs = clientArgs; this.clientArgs = clientArgs;
this.compatClasses = compatClasses; this.compatClasses = compatClasses;
@ -160,6 +167,14 @@ public String[] getClassPath() {
return classPath.toArray(new String[0]); return classPath.toArray(new String[0]);
} }
public List<String> getModulePath() {
return Collections.unmodifiableList(modulePath);
}
public List<String> getModules() {
return Collections.unmodifiableList(modules);
}
public String[] getAlternativeClassPath() { public String[] getAlternativeClassPath() {
return altClassPath.toArray(new String[0]); return altClassPath.toArray(new String[0]);
} }

View file

@ -12,6 +12,8 @@ public class ClientProfileBuilder {
private Set<OptionalFile> updateOptional = new HashSet<>(); private Set<OptionalFile> updateOptional = new HashSet<>();
private List<String> jvmArgs = new ArrayList<>(); private List<String> jvmArgs = new ArrayList<>();
private List<String> classPath = new ArrayList<>(); private List<String> classPath = new ArrayList<>();
private List<String> modulePath = new ArrayList<>();
private List<String> modules = new ArrayList<>();
private List<String> altClassPath = new ArrayList<>(); private List<String> altClassPath = new ArrayList<>();
private List<String> clientArgs = new ArrayList<>(); private List<String> clientArgs = new ArrayList<>();
private List<String> compatClasses = new ArrayList<>(); private List<String> compatClasses = new ArrayList<>();
@ -142,6 +144,16 @@ public ClientProfileBuilder setRecommendJavaVersion(int recommendJavaVersion) {
return this; return this;
} }
public ClientProfileBuilder setModulePath(List<String> modulePath) {
this.modulePath = modulePath;
return this;
}
public ClientProfileBuilder setModules(List<String> modules) {
this.modules = modules;
return this;
}
public ClientProfileBuilder setMinJavaVersion(int minJavaVersion) { public ClientProfileBuilder setMinJavaVersion(int minJavaVersion) {
this.minJavaVersion = minJavaVersion; this.minJavaVersion = minJavaVersion;
return this; return this;
@ -193,6 +205,6 @@ public ClientProfileBuilder setMainClass(String mainClass) {
} }
public ClientProfile createClientProfile() { public ClientProfile createClientProfile() {
return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass); return new ClientProfile(update, updateExclusions, updateShared, updateVerify, updateOptional, jvmArgs, classPath, modulePath, modules, altClassPath, clientArgs, compatClasses, properties, servers, securityManagerConfig, classLoaderConfig, signedClientConfig, runtimeInClientConfig, version, assetIndex, dir, assetDir, recommendJavaVersion, minJavaVersion, maxJavaVersion, warnMissJavaVersion, settings, sortIndex, uuid, title, info, updateFastCheck, mainClass);
} }
} }

@ -1 +1 @@
Subproject commit aea93d6803e4770f23ff4a2ea4b5f8752d053d8b Subproject commit a1318b09c1f5657ad60eaee362746cd493d38c8a