diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc1402b62..c807301c9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] kotlin = "1.9.24" -asm = "9.6" +asm = "9.7.1" commons-io = "2.15.1" gson = "2.10.1" guava = "33.0.0-jre" diff --git a/gradle/test.libs.versions.toml b/gradle/test.libs.versions.toml index c3c92e8bf..2b091d911 100644 --- a/gradle/test.libs.versions.toml +++ b/gradle/test.libs.versions.toml @@ -6,7 +6,7 @@ mockito = "5.13.0" java-debug = "0.52.0" mixin = "0.15.3+mixin.0.8.7" -gradle-nightly = "8.11-20240926001708+0000" +gradle-nightly = "8.12-20241009055624+0000" fabric-loader = "0.16.5" fabric-installer = "1.0.1" diff --git a/src/main/java/net/fabricmc/loom/util/gradle/WorkerDaemonClientsManagerHelper.java b/src/main/java/net/fabricmc/loom/util/gradle/WorkerDaemonClientsManagerHelper.java index d51f79206..07d2f0375 100644 --- a/src/main/java/net/fabricmc/loom/util/gradle/WorkerDaemonClientsManagerHelper.java +++ b/src/main/java/net/fabricmc/loom/util/gradle/WorkerDaemonClientsManagerHelper.java @@ -32,6 +32,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.gradle.api.Transformer; +import org.gradle.process.internal.JvmOptions; import org.gradle.workers.internal.DaemonForkOptions; import org.gradle.workers.internal.WorkerDaemonClientsManager; @@ -45,7 +46,7 @@ public static boolean stopIdleJVM(WorkerDaemonClientsManager manager, String jvm Transformer, List> transformer = workerDaemonClients -> { for (Object /* WorkerDaemonClient */ client : workerDaemonClients) { DaemonForkOptions forkOptions = getForkOptions(client); - Map systemProperties = forkOptions.getJavaForkOptions().getSystemProperties(); + Map systemProperties = getSystemProperties(forkOptions); if (systemProperties == null || !jvmMarkerValue.equals(systemProperties.get(MARKER_PROP))) { // Not the JVM we are looking for @@ -70,6 +71,30 @@ public static boolean stopIdleJVM(WorkerDaemonClientsManager manager, String jvm return stopped.get(); } + private static Map getSystemProperties(DaemonForkOptions forkOptions) { + try { + Method getJavaForkOptionsMethod = forkOptions.getClass().getDeclaredMethod("getJavaForkOptions"); + getJavaForkOptionsMethod.setAccessible(true); + Object /* JavaForkOptions */ javaForkOptions = getJavaForkOptionsMethod.invoke(forkOptions); + Method getSystemPropertiesMethod = javaForkOptions.getClass().getDeclaredMethod("getSystemProperties"); + getSystemPropertiesMethod.setAccessible(true); + //noinspection unchecked + return (Map) getSystemPropertiesMethod.invoke(javaForkOptions); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + // Gradle 8.11 and below + } + + // Gradle 8.12+ + try { + Method getJvmOptions = forkOptions.getClass().getDeclaredMethod("getJvmOptions"); + getJvmOptions.setAccessible(true); + JvmOptions jvmOptions = (JvmOptions) getJvmOptions.invoke(forkOptions); + return jvmOptions.getMutableSystemProperties(); + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException("Failed to daemon system properties", e); + } + } + private static DaemonForkOptions getForkOptions(Object /* WorkerDaemonClient */ client) { try { Method getForkOptionsMethod = client.getClass().getDeclaredMethod("getForkOptions");