while migrating to kotlin 2.0.0 i got this error o...
# multiplatform
y
while migrating to kotlin 2.0.0 i got this error on this line of code
Copy code
jvm("desktop") {
    jvmToolchain(17)
}
Using 'jvmToolchain(Int): Unit' is an error. Configuring JVM toolchain in the Kotlin target level DSL is prohibited. JVM toolchain feature should be configured in the extension scope as it affects all JVM targets (JVM, Android).
h
As the error message said, move it one line (scope) up.
1
y
it got deprecated better use this instead
Copy code
jvm("desktop") {
    compilerOptions {
        apiVersion.set(org.jetbrains.kotlin.gradle.dsl.KotlinVersion.KOTLIN_2_0)
    }
}
h
The language version is unrelated.
1
a
This is the correct way to set the JVM toolchain:
Copy code
kotlin {
  jvmToolchain(17)
  jvm("desktop")
}
👍 3
204 Views