Skip to content
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

Open
wants to merge 1 commit into
base: 1.21.x
Choose a base branch
from

Conversation

sciwhiz12
Copy link
Member

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.)

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.)
@sciwhiz12 sciwhiz12 added enhancement New (or improvement to existing) feature or request ci/build Related to continuous integration/build system 1.21.3 Targeted at Minecraft 1.21.3 labels Nov 18, 2024
@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented Nov 18, 2024

  • Publish PR to GitHub Packages

Last commit published: 2975f498949299648443c3b6fe24916bd626ddb3.

PR Publishing

The artifacts published by this PR:

Repository Declaration

In 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 installation

In order to setup a MDK using the latest PR version, run the following commands in a terminal.
The script works on both *nix and Windows as long as you have the JDK bin folder on the path.
The script will clone the MDK in a folder named NeoForge-pr1692.
On Powershell you will need to remove the -L flag from the curl invocation.

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.

@lukebemish
Copy link
Contributor

lukebemish commented Nov 18, 2024

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)

@sciwhiz12 sciwhiz12 self-assigned this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.3 Targeted at Minecraft 1.21.3 ci/build Related to continuous integration/build system enhancement New (or improvement to existing) feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants