-
-
Notifications
You must be signed in to change notification settings - Fork 424
Description
Expected and Results
#1199 introduced the missing "org.gradle.jvm.version" attribute for the module metadata of the shadowed artifacts. The version is however not resolved to the correct JVM version in all cases.
Related environment and versions
Shadow: 9.0.0-rc1
Reproduction steps
Consider the following example:
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}
tasks.compileJava {
options.release = 8
}(See this blog post for why you'd want to do this)
This produces a jar compatible with Java 8, but when also applying the shadow plugin it claims it was compiled against Java 21.
Anything else?
The implementation currently only looks at targetCompatibility
shadow/src/main/kotlin/com/github/jengelman/gradle/plugins/shadow/ShadowJavaPlugin.kt
Lines 78 to 82 in b224199
| val targetJvmVersion = provider { | |
| javaPluginExtension.targetCompatibility.majorVersion.toInt() | |
| } | |
| // Track JavaPluginExtension to update targetJvmVersion when it changes. | |
| attr.attributeProvider(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, targetJvmVersion) |
The corresponding implementation in Gradle seems to take a few more cases into consideration:
https://github.com/gradle/gradle/blob/b06b7de4572c102a02ed831ae1f37e2da8255c35/platforms/jvm/plugins-java-base/src/main/java/org/gradle/api/plugins/jvm/internal/DefaultJvmLanguageUtilities.java#L64-L114