-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
Specify Java language level in module plugin #3732
Specify Java language level in module plugin #3732
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3732 +/- ##
=========================================
Coverage 78.04% 78.04%
Complexity 2883 2883
=========================================
Files 473 473
Lines 9300 9300
Branches 1767 1767
=========================================
Hits 7258 7258
Misses 1078 1078
Partials 964 964 Continue to review full report at Codecov.
|
@@ -73,6 +73,8 @@ dependencies { | |||
java { | |||
withSourcesJar() | |||
withJavadocJar() | |||
sourceCompatibility = JavaVersion.VERSION_1_8 |
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.
Shouldn't need sourceCompatibility
set here, since there's no Java source in the project.
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.
I believe you're right, although I wasn't able to find any reference that sourceCompatibility
is using only for compilation of Java file and I can't exclude other side effects. I won't mind keeping both.
@@ -73,6 +73,8 @@ dependencies { | |||
java { | |||
withSourcesJar() | |||
withJavadocJar() | |||
sourceCompatibility = JavaVersion.VERSION_1_8 | |||
targetCompatibility = JavaVersion.VERSION_1_8 |
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.
Dropping targetCompatibility
in #3575 breaking things here is unfortunate, and obviously not expected :(. Kotlin apparently ignores the jvmTarget
option on the compilation tasks, or at least that value doesn't filter down to the generated JARs.
JetBrains says the proper way to set the value is with this:
configurations["runtimeElements"].attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
}
But I agree setting targetCompatibility
here is easier to understand.
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.
Yeah the suggested approach feel really fragile. I've ⭐ the YouTrack issue. Ideally this could be addressed by the KGP in some form.
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.
This is probably the behavior configured in Gradle: https://github.com/gradle/gradle/blob/v7.0.0/subprojects/plugins/src/main/java/org/gradle/api/plugins/jvm/internal/DefaultJvmPluginServices.java#L211 - The target compatibility is used to configure the org.gradle.jvm.version
attribute
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.
This is probably worth paying attention to in future Gradle upgrades.
This PR is likely not necessary when we bump to Kotlin 1.5
|
From #3727 (comment)
We need to specify the Java
sourceCompatibility
andtargetCompatibility
inside themodule
plugin.Sadly the -RC1 was build with JDK11 and and this makes it unusable for users on JRE 8
Fixes #3731