mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Support lmodule with Java 17
This commit is contained in:
parent
b31dd78b2b
commit
6e45a84c1c
6 changed files with 22 additions and 4 deletions
|
@ -45,6 +45,7 @@ public class BuildContext {
|
|||
public final MainBuildTask task;
|
||||
public final HashSet<String> fileList;
|
||||
public final HashSet<String> clientModules;
|
||||
public final HashSet<String> legacyClientModules;
|
||||
|
||||
public BuildContext(ZipOutputStream output, List<JarFile> readerClassPath, MainBuildTask task) {
|
||||
this.output = output;
|
||||
|
@ -52,6 +53,7 @@ public BuildContext(ZipOutputStream output, List<JarFile> readerClassPath, MainB
|
|||
this.task = task;
|
||||
fileList = new HashSet<>(1024);
|
||||
clientModules = new HashSet<>();
|
||||
legacyClientModules = new HashSet<>();
|
||||
}
|
||||
|
||||
public void pushFile(String filename, InputStream inputStream) throws IOException {
|
||||
|
|
|
@ -56,6 +56,7 @@ public Path process(Path inputJar) throws IOException {
|
|||
BuildContext context = new BuildContext(output, reader.getCp(), this);
|
||||
initProps();
|
||||
preBuildHook.hook(context);
|
||||
properties.put("launcher.legacymodules", context.legacyClientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
||||
properties.put("launcher.modules", context.clientModules.stream().map(e -> Type.getObjectType(e.replace('.', '/'))).collect(Collectors.toList()));
|
||||
postInitProps();
|
||||
reader.getCp().add(new JarFile(inputJar.toFile()));
|
||||
|
|
|
@ -50,7 +50,11 @@ public void init() {
|
|||
mainTask.preBuildHook.registerHook((buildContext) -> {
|
||||
for (ModuleEntity e : launcherModules) {
|
||||
if (e.propertyMap != null) buildContext.task.properties.putAll(e.propertyMap);
|
||||
buildContext.clientModules.add(e.moduleMainClass);
|
||||
if(e.modernModule) {
|
||||
buildContext.clientModules.add(e.moduleMainClass);
|
||||
} else {
|
||||
buildContext.legacyClientModules.add(e.moduleMainClass);
|
||||
}
|
||||
buildContext.readerClassPath.add(new JarFile(e.path.toFile()));
|
||||
}
|
||||
});
|
||||
|
@ -94,6 +98,7 @@ public static class ModuleEntity {
|
|||
public String moduleMainClass;
|
||||
public String moduleConfigClass;
|
||||
public String moduleConfigName;
|
||||
public boolean modernModule;
|
||||
public Map<String, Object> propertyMap;
|
||||
}
|
||||
|
||||
|
@ -120,6 +125,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO
|
|||
entity.path = file;
|
||||
entity.moduleMainClass = mainClass;
|
||||
entity.moduleConfigClass = attributes.getValue("Module-Config-Class");
|
||||
String requiredModernJava = attributes.getValue("Required-Modern-Java");
|
||||
entity.modernModule = Boolean.parseBoolean(requiredModernJava);
|
||||
if (entity.moduleConfigClass != null) {
|
||||
entity.moduleConfigName = attributes.getValue("Module-Config-Name");
|
||||
if (entity.moduleConfigName == null) {
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
-dontshrink
|
||||
-dontoptimize
|
||||
-ignorewarnings
|
||||
-target 8
|
||||
-forceprocessing
|
||||
|
||||
-repackageclasses 'pro.gravit.launcher'
|
||||
|
|
|
@ -224,8 +224,8 @@ public void start(String... args) throws Throwable {
|
|||
}
|
||||
};
|
||||
}
|
||||
service.registerEventHandler(new BasicLauncherEventHandler());
|
||||
}
|
||||
Request.getRequestService().registerEventHandler(new BasicLauncherEventHandler());
|
||||
Objects.requireNonNull(args, "args");
|
||||
if (started.getAndSet(true))
|
||||
throw new IllegalStateException("Launcher has been already started");
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import pro.gravit.launcher.serialize.HInput;
|
||||
import pro.gravit.launcher.serialize.HOutput;
|
||||
import pro.gravit.launcher.serialize.stream.StreamObject;
|
||||
import pro.gravit.utils.helper.JVMHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
@ -21,7 +22,7 @@
|
|||
public final class LauncherConfig extends StreamObject {
|
||||
@LauncherInject("launchercore.certificates")
|
||||
private static final List<byte[]> secureConfigCertificates = null;
|
||||
@LauncherInject("launcher.modules")
|
||||
@LauncherInject("launcher.legacymodules")
|
||||
private static final List<Class<?>> modulesClasses = null;
|
||||
private static final MethodType VOID_TYPE = MethodType.methodType(void.class);
|
||||
@LauncherInject("launcher.projectName")
|
||||
|
@ -51,6 +52,11 @@ public final class LauncherConfig extends StreamObject {
|
|||
@LauncherInject("runtimeconfig.buildNumber")
|
||||
public long buildNumber;
|
||||
|
||||
private static class ModernModulesClass {
|
||||
@LauncherInject("launcher.modules")
|
||||
private static final List<Class<?>> modulesClasses = null;
|
||||
}
|
||||
|
||||
|
||||
@LauncherInjectionConstructor
|
||||
public LauncherConfig(HInput input) throws IOException, InvalidKeySpecException {
|
||||
|
@ -114,6 +120,9 @@ public LauncherConfig(String address, Map<String, byte[]> runtime, String projec
|
|||
}
|
||||
|
||||
public static void initModules(LauncherModulesManager modulesManager) {
|
||||
if(JVMHelper.JVM_VERSION >= 17) {
|
||||
modulesClasses.addAll(ModernModulesClass.modulesClasses);
|
||||
}
|
||||
for (Class<?> clazz : modulesClasses)
|
||||
try {
|
||||
modulesManager.loadModule((LauncherModule) MethodHandles.publicLookup().findConstructor(clazz, VOID_TYPE).invokeWithArguments(Collections.emptyList()));
|
||||
|
|
Loading…
Reference in a new issue