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

[Feature]: Introduce java version management #181

Closed
wants to merge 3 commits into from

Conversation

marchermans
Copy link
Contributor

When creating a runtime, NG7 will automatically set the required java version for your game version.

@neoforged-pr-publishing
Copy link

neoforged-pr-publishing bot commented May 18, 2024

  • Publish PR to GitHub Packages

Last commit published: 5a80e9fd1fbb1551159f9bfdd035a6fb13038bf4.

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 #181' // https://github.com/neoforged/NeoGradle/pull/181
        url 'https://prmaven.neoforged.net/NeoGradle/pr181'
        content {
            includeModule('net.neoforged.gradle.common', 'net.neoforged.gradle.common.gradle.plugin')
            includeModule('net.neoforged.gradle', 'common')
            includeModule('net.neoforged.gradle', 'dsl-platform')
            includeModule('net.neoforged.gradle', 'dsl-mixin')
            includeModule('net.neoforged.gradle', 'dsl-common')
            includeModule('net.neoforged.gradle', 'dsl-userdev')
            includeModule('net.neoforged.gradle', 'dsl-vanilla')
            includeModule('net.neoforged.gradle', 'dsl-neoform')
            includeModule('net.neoforged.gradle', 'userdev')
            includeModule('net.neoforged.gradle', 'neoform')
            includeModule('net.neoforged.gradle.platform', 'net.neoforged.gradle.platform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'utils')
            includeModule('net.neoforged.gradle.neoform', 'net.neoforged.gradle.neoform.gradle.plugin')
            includeModule('net.neoforged.gradle', 'mixin')
            includeModule('net.neoforged.gradle.mixin', 'net.neoforged.gradle.mixin.gradle.plugin')
            includeModule('net.neoforged.gradle', 'platform')
            includeModule('net.neoforged.gradle.vanilla', 'net.neoforged.gradle.vanilla.gradle.plugin')
            includeModule('net.neoforged.gradle', 'vanilla')
            includeModule('net.neoforged.gradle.userdev', 'net.neoforged.gradle.userdev.gradle.plugin')
        }
    }
}

@@ -0,0 +1,29 @@
package net.neoforged.gradle.common.extensions;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just.. set the version? What's the point of this extension?

}

public void setJavaVersion(int javaVersion, String context) {
if (this.javaVersion > javaVersion) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic needs to be the other way around. In the case where there's 2 neo deps in the same project, the project must compile with the lowest Java version so that both sourcesets will work. Compiling with the highest will cause the one needing the lower to crash at runtime, and even if target compatibility were set, one can easily run into the issue of using newer Java methods.

Copy link
Contributor

@lukebemish lukebemish May 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that the toolchain is used for running too, and for running you definitely need the newest. And NG doesn't currently have an easy way to use a separate javalauncher for a given run configuration it seems? Maybe the real solution would be to add that -- then the runs with a given MC version could use the one for that MC version and the root toolchain would use the oldest.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarfy, not just running, also decompile and recompile need the newest versions, so this is the correct default behaviour.

@marchermans
Copy link
Contributor Author

Closing PR as this is a chicken and egg situation:
Need to resolve a configuration to download tools and the version json data.
This causes the java version to become final.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants