Open sciwhiz12 opened 4 days ago
Last commit published: 2975f498949299648443c3b6fe24916bd626ddb3.
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.)