How do I set the project language level so Gradle ...
# gradle
t
How do I set the project language level so Gradle import in IntelliJ won't forget it again and again. I use this now, but it seems to have no effect:
Copy code
jvm {
        @OptIn(ExperimentalKotlinGradlePluginApi::class)
        compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
    }
s
Copy code
kotlin.jvmToolchain(11)
That'll probably force it to use JDK 11 to build too, though. For a gentler approach you could try
Copy code
kotlin.compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
t
Is there a difference between the one you posted second and the way I set it up? I use jvmToolChain as well.
t
Do you configure it in KMP project?
t
Yes.
2.0.0, IDEA is 2024.1.4
Copy code
kotlin {

    jvmToolchain(11)

    jvm {
        @OptIn(ExperimentalKotlinGradlePluginApi::class)
        compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
    }

    js(IR) {
        browser()
        binaries.library()
    }
t
I think this picture should help better to understand:
in your case configuration is not applied to shared source sets (
common
) and that is why IDEA complains
t
The code in question is in
jvmMain
.
t
do you have a repro?
t
Thank you for the attention.
This is what appears up again and again. If I set the project language level in idea it goes away, but the language level goes back to 6 after a while (I guess it's the gradle import)
t
which IDEA version are you using?
t
2024.1.4
Maybe the problem is the composite project, so IDEA cannot figure the level for it? Just guessing.
t
https://youtrack.jetbrains.com/issue/KTIJ-25134 - could you check 2024.2 release?
t
Thanks, I'll mark that issue.
a
Hi, unfortunately, the issue above is not yet cherry-picked to 242, but it should be there soon
thank you color 1