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

Specify Java language level in module plugin #3732

Merged
merged 1 commit into from
May 2, 2021

Conversation

cortinico
Copy link
Member

@cortinico cortinico commented May 2, 2021

From #3727 (comment)

We need to specify the Java sourceCompatibility and targetCompatibility inside the module plugin.
Sadly the -RC1 was build with JDK11 and and this makes it unusable for users on JRE 8

Fixes #3731

@cortinico cortinico added this to the 1.17.0 milestone May 2, 2021
@cortinico cortinico added the housekeeping Marker for housekeeping tasks and refactorings label May 2, 2021
@codecov
Copy link

codecov bot commented May 2, 2021

Codecov Report

Merging #3732 (0501d40) into main (50b453b) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 50b453b...0501d40. Read the comment docs.

@@ -73,6 +73,8 @@ dependencies {
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = JavaVersion.VERSION_1_8
Copy link
Member

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.

Copy link
Member Author

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
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member

@chao2zhang chao2zhang left a 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.

@chao2zhang chao2zhang merged commit 3120e35 into detekt:main May 2, 2021
@chao2zhang
Copy link
Member

This PR is likely not necessary when we bump to Kotlin 1.5
https://blog.jetbrains.com/kotlin/2021/05/kotlin-1-5-0-released/

New default JVM target: 1.8. The 1.6 target is deprecated.

chao2zhang pushed a commit to chao2zhang/detekt that referenced this pull request May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
housekeeping Marker for housekeeping tasks and refactorings
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle plugin no longer supporting Java 1.8 with 1.17.0-RC1, by accident?
3 participants