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

Support jvmTarget 17 #4287

Closed
eygraber opened this issue Nov 18, 2021 · 12 comments · Fixed by #4277
Closed

Support jvmTarget 17 #4287

eygraber opened this issue Nov 18, 2021 · 12 comments · Fixed by #4277
Labels
Milestone

Comments

@eygraber
Copy link
Contributor

Currently setting it to 17 results in Invalid value passed to --jvm-target

@eygraber
Copy link
Contributor Author

It seems like the issue is that I tried doing this in an included build. It works fine otherwise. Not sure why it doesn't work in included builds, but I'm guessing it's not a detekt issue.

@eygraber
Copy link
Contributor Author

This project has a buildSrc that works fine with jvmTarget = "17" but the included build doesn't.

I just ran into this issue in another project that tries to use jvmTarget = "17" for a regular module, but it doesn't work (Invalid value passed to --jvm-target).

Maybe there is something going on here?

@eygraber eygraber reopened this Nov 25, 2021
@eygraber
Copy link
Contributor Author

Here's my config:

detekt {
  toolVersion = libs.versions.detekt.get()

  source.from("build.gradle.kts")

  autoCorrect = true
  parallel = true

  buildUponDefaultConfig = true

  config = project.files("${project.rootDir}/detekt.yml")
}

tasks.withType<Detekt>().configureEach {
  // Target version of the generated JVM bytecode. It is used for type resolution.
  jvmTarget = libs.versions.jdk.get()
}

@chao2zhang
Copy link
Member

Kotlin 1.5.3X seems to support up to Java 16 as the target: https://github.com/JetBrains/kotlin/blob/1.5.30/compiler/config.jvm/src/org/jetbrains/kotlin/config/JvmTarget.kt.

I see that JVM_17 was added in Kotlin 1.6.0, so hopefully this is unblocked by #4277

@3flex 3flex mentioned this issue Nov 29, 2021
@3flex
Copy link
Member

3flex commented Nov 29, 2021

I see that JVM_17 was added in Kotlin 1.6.0, so hopefully this is unblocked by #4277

I've manually tested, and yes, #4277 should fix the issue. This issue will be closed when that PR is merged.

@3flex 3flex added this to the 1.20.0 milestone Nov 29, 2021
@vladimirfx
Copy link

Working workaround:

dependencies {
    detekt("io.gitlab.arturbosch.detekt:detekt-cli:1.19.0")
    detekt("org.jetbrains.kotlin:kotlin-compiler-embeddable:1.6.0")
}

@eygraber
Copy link
Contributor Author

eygraber commented Apr 7, 2022

This is still happening sporadically in 1.20.0-RC2

Maybe related to detekt getting set up in a Gradle precompiled script plugin, which uses Kotlin 1.5.31

Looks like the issue is that the snapshots aren't updated since November.

@cortinico
Copy link
Member

Looks like the issue is that the snapshots aren't updated since November.

Not sure what you refer to, but the last snapshot was published today:
https://oss.sonatype.org/content/repositories/snapshots/io/gitlab/arturbosch/detekt/

@eygraber
Copy link
Contributor Author

eygraber commented Apr 7, 2022

Ah I was looking at a different view of the snapshot repo.

Well then this is still an issue. Like I said above:

Maybe related to detekt getting set up in a Gradle precompiled script plugin, which uses Kotlin 1.5.31

@3flex
Copy link
Member

3flex commented Apr 7, 2022

Do you have a complete reproducer to share? It shouldn't matter that detekt is setup in a precompiled script plugin - the classpath used by detekt when it runs should be isolated from that used by Gradle. We can verify with a build scan (that would also help in the absence of a complete repro).

@eygraber
Copy link
Contributor Author

eygraber commented Apr 7, 2022

I'm working on putting something together. It also could be that I have custom rules that are on an older version of detekt, so I'm going to try to update those first.

@eygraber
Copy link
Contributor Author

eygraber commented Apr 8, 2022

False alarm, it was only happening when I used main-SNAPSHOT, and it looks like the issue is that I set toolVersion to the same version that I use for the dependency, and it didn't like using main-SNAPSHOT for that. So I changed toolVersion to use 1.20.0-RC2 and then it worked.

It's a little odd because I made a fresh project with all of the same configuration and it didn't have this issue. Maybe something weird got stuck in the cache.

Update Updating my project to Kotlin 1.6.20 from 1.6.10 solved the issue. Still weird because the fresh project was also using 1.6.10 and didn't fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants