Can intelliJ detect the JVM toolchain/target versi...
# intellij
m
Can intelliJ detect the JVM toolchain/target version of some file based on Gradle configuration?
Thread.id
is deprecated in Java 19 (which is my JAVA_HOME). But I'm compiling with
jvmTarget = "1.8"
so it shouldn't be a warning?
Changing Project settings fixes it but it feels wrong to have to duplicate this?
Also interestingly, it seems to be bound to the SDK version while I would expect it to be bound to the Language Level instead
r
If I remember correctly, this can be controlled by the Java toolchain version in the Gradle build file (https://docs.gradle.org/current/userguide/toolchains.html), I don't think the Kotlin compiler plugin will automatically take over the Java toolchain JVM version, but you could at least use a common property for it, something like (assuming a
build.gradle.kts
):
Copy code
val jvmVersion = 19

java {
    toolchain.languageVersion.set(JavaLanguageVersion.of(jvmVersion))
}

tasks.compileKotlin {
    kotlinOptions {
        jvmTarget = "$jvmVersion"
    }
}
m
That part works. My issue is with IntelliJ is not picking this up
i.e. it shows false positive warnings
r
ah okay, then I misunderstood!
s
I think it on the way. Scroll down to
Java SDK detected from the Gradle toolchain
https://blog.jetbrains.com/idea/2023/02/intellij-idea-2023-1-eap-6
👀 1
m
Oohhooh very nice
I'm already on 2023.1 though 🤔 . Let me try again
So that doesn't work out of the box (I'm using toolchains with Java17)
Trying to clean my .idea folder