-
Notifications
You must be signed in to change notification settings - Fork 3
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
Java compatibility forced to match Gradle minimum Java compatability #95
Comments
It looks like this might have been fixed on the main branch. There does not appear to be a release yet with these changes though. |
The new and old codes accounted for this by only forcing JVM compatibility if the user didn't specify anything. I checked, and it does work. However... I see the issue. Gradle automatically set the source compatibility when setting the target compatibility, which is what was left out. Could you confirm that you only set the target compatibility? |
It is actually still broken on master. I'm using a java toolchain instead of source/target compatibility
The problem is that the plugin is setting the source compatibility value to 1.1 in InjectJvmCompatibilityPropertyIntoJavaExtensionRule.onExtension(JavaPluginExtension). That value ends up taking precedence over the toolchain version in DefaultJavaPluginExtension.getSourceCompatibility() meaning the toolchain version is never checked. As a result the logic to set the jvm compatibility version to the minimum version supported by the target version of gradle is called. |
Version 1.6.13 should fix the issue. Please reopen if the problem is still present. |
The fix in java {
toolchain {
languageVersion = JavaLanguageVersion.of(22)
}
}
withType<JavaCompile>().configureEach {
options.release = 8
} This configuration uses the latest toolchain to compile for a specific Java version. However, as of the changes in 1.6.13, this is no longer supported. The culprit seems to be that the compatibility versions are set to the toolchain versions regardless of whether For example, this issue surfaces when writing a plugin in Kotlin: kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_1_8
}
} Running a build then fails even if
|
Opened #113 for visibility |
When specifying a minimum Gradle version the plugin forces the java compatibility to match the Gradle minimum compatibility version here. This prevents plugins from building with a newer JDK because dependencies will fail to get pulled when running with newer versions of Gradle due to variant JDK version missmatches.
- Incompatible because this component declares a component, compatible with Java 17 and the consumer needed a component, compatible with Java 8
Users should be able to set compatibility to a version higher than the minimum Gradle java version.
The text was updated successfully, but these errors were encountered: