Enable Daemon JVM discovery to Java 21 #1692
Open
+16
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.)