From 1bd5d8854c584eab5c688227247e6194f2040986 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Wed, 17 Jul 2024 01:32:51 +0700 Subject: [PATCH] [FIX] ProGuard and launchserver.dir.libraries --- .../main/java/pro/gravit/launchserver/LaunchServer.java | 8 ++++++-- .../gravit/launchserver/components/ProGuardComponent.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java index d3adfbae..6a50ae8e 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServer.java @@ -84,6 +84,7 @@ public final class LaunchServer implements Runnable, AutoCloseable, Reconfigurab public final Path tmpDir; public final Path modulesDir; public final Path launcherModulesDir; + public final Path librariesDir; /** * This object contains runtime configuration */ @@ -140,6 +141,7 @@ public LaunchServer(LaunchServerDirectories directories, LaunchServerEnv env, La launcherPack = directories.launcherPackDir; modulesDir = directories.modules; launcherModulesDir = directories.launcherModules; + librariesDir = directories.launcherLibrariesDir; this.shardId = shardId; if(!Files.isDirectory(launcherPack)) { Files.createDirectories(launcherPack); @@ -495,9 +497,10 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO public static class LaunchServerDirectories { public static final String UPDATES_NAME = "updates", PROFILES_NAME = "profiles", TRUSTSTORE_NAME = "truststore", LAUNCHERLIBRARIES_NAME = "launcher-libraries", - LAUNCHERLIBRARIESCOMPILE_NAME = "launcher-libraries-compile", LAUNCHERPACK_NAME = "launcher-pack", KEY_NAME = ".keys", MODULES = "modules", LAUNCHER_MODULES = "launcher-modules"; + LAUNCHERLIBRARIESCOMPILE_NAME = "launcher-libraries-compile", LAUNCHERPACK_NAME = "launcher-pack", KEY_NAME = ".keys", MODULES = "modules", LAUNCHER_MODULES = "launcher-modules", LIBRARIES = "libraries"; public Path updatesDir; public Path profilesDir; + public Path librariesDir; public Path launcherLibrariesDir; public Path launcherLibrariesCompileDir; public Path launcherPackDir; @@ -515,11 +518,12 @@ public void collect() { if (launcherLibrariesDir == null) launcherLibrariesDir = getPath(LAUNCHERLIBRARIES_NAME); if (launcherLibrariesCompileDir == null) launcherLibrariesCompileDir = getPath(LAUNCHERLIBRARIESCOMPILE_NAME); - if(launcherPackDir == null) + if (launcherPackDir == null) launcherPackDir = getPath(LAUNCHERPACK_NAME); if (keyDirectory == null) keyDirectory = getPath(KEY_NAME); if (modules == null) modules = getPath(MODULES); if (launcherModules == null) launcherModules = getPath(LAUNCHER_MODULES); + if (librariesDir == null) librariesDir = getPath(LIBRARIES); if (tmpDir == null) tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("launchserver-%s".formatted(SecurityHelper.randomStringToken())); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java index 97a36b49..9b1586bb 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/components/ProGuardComponent.java @@ -213,7 +213,7 @@ public Path process(Path inputFile) throws IOException { args.add(IOHelper.resolveJavaBin(IOHelper.JVM_DIR).toAbsolutePath().toString()); args.addAll(component.jvmArgs); args.add("-cp"); - try(Stream files = Files.walk(Path.of("libraries"), FileVisitOption.FOLLOW_LINKS)) { + try(Stream files = Files.walk(server.librariesDir, FileVisitOption.FOLLOW_LINKS)) { args.add(files .filter(e -> e.getFileName().toString().endsWith(".jar")) .map(path -> path.toAbsolutePath().toString())