-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable Daemon JVM discovery to Java 21 #1692
base: 1.21.x
Are you sure you want to change the base?
Conversation
Due to the way that Gradle forks (or rather, doesn't fork) the compiler when the compile task's JVM differs from the Daemon's JVM, if the Gradle Daemon is not running on Java 21, trying to compile the NeoForge sources will result in an OutOfMemory error. To avoid this being a silent problem that is hard to diagnose and figure out for developers, the Daemon JVM discovery feature is configured to require and use a Java 21 JVM for the Daemon. (As of Gradle 8.10, Daemon JVM discovery does not do auto-provisioning in the same way as the Java toolchains feature does, so the developer has to install a Java 21 JVM if they do not have one already.)
Last commit published: 2975f498949299648443c3b6fe24916bd626ddb3. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #1692' // https://github.com/neoforged/NeoForge/pull/1692
url 'https://prmaven.neoforged.net/NeoForge/pr1692'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr1692
cd NeoForge-pr1692
curl -L https://prmaven.neoforged.net/NeoForge/pr1692/net/neoforged/neoforge/21.3.35-beta-pr-1692-daemon-jvm-discovery/mdk-pr1692.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
Any reason you can't just do options.fork = true If the issue is gradle failing to fork the JVM? (And then setting the forked memory if necessary? As in, it is necessary, set the compiler memory by forked jvm settings and make it always fork and it'll be fine) Daemon toolchain discovery seems like overkill here when importing the project when only, say, J23 is available should work fine and download a J21 javac via toolchains -- but with a daemon toolchain set, this would fail outright if you don't have J21 locally, instead of letting it be discovered via foojay (in other words, it removes all benefits of project level toolchains and foojay) |
This PR enables the Gradle Daemon JVM discovery feature and sets it to require and use a Java 21 JVM for the Gradle Daemon. For documentation's sake, the task is configured in the buildscript as to be an appropriate place to add a comment for it.
Due to the way that Gradle forks (or rather, doesn't fork) the compiler when the compile task's JVM differs from the Daemon's JVM, if the Gradle Daemon is not running on Java 21 (whether a lower or a higher version), trying to compile the NeoForge sources will result in an OutOfMemory error. (Ask @Technici4n on the details; I myself don't know much except of the results.)
To avoid this being a silent problem that is hard to diagnose and figure out for developers, the Daemon JVM discovery feature is configured to require and use a Java 21 JVM for the Daemon. (As of Gradle 8.10, Daemon JVM discovery does not do auto-provisioning in the same way as the Java toolchains feature does, so the developer has to install a Java 21 JVM if they do not have one already.)