-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
Last commit published: 5a80e9fd1fbb1551159f9bfdd035a6fb13038bf4. 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 #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; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
common/src/main/java/net/neoforged/gradle/common/extensions/JavaVersionManager.java
Outdated
Show resolved
Hide resolved
Closing PR as this is a chicken and egg situation: |
When creating a runtime, NG7 will automatically set the required java version for your game version.