Generating a new JDK 21 Kotlin Gradle project when using JDK 22 locally results in Kotlin target JDK mismatch causing the sync to fail. For example, new Spring Boot projects automatically set the Java language version using Gradle's JavaToolchain support.
Task List
[x] Steps to reproduce provided
[ ] Stacktrace (if present) provided
[ ] Example that reproduces the problem uploaded to Github
[x] Full description of the issue provided (see below)
Steps to Reproduce
Create a starter using Java 21 w/o any plugins using Kotlin & Kotlin Gradle
Have JDK 22 as Java Home
Sync project, notice the warning that Kotlin is incompatible with 22 JDK target, it downgrades to 21 automatically
Kotlin does not yet support 22 JDK target, falling back to Kotlin JVM_21 JVM target
Change Java sourceCompatability to 17
Try to resync & run the app and notice error:
> Inconsistent JVM-target compatibility detected for tasks 'compileJava' (17) and 'kspKotlin' (21).
Expected Behaviour
kspKotlin and compileJava should use the same language version automatically.
Actual Behaviour
kspKotlin and compileJava use different JVM target versions.
Description
Generating a new JDK 21 Kotlin Gradle project when using JDK 22 locally results in Kotlin target JDK mismatch causing the sync to fail. For example, new Spring Boot projects automatically set the Java language version using Gradle's JavaToolchain support.
Task List
Steps to Reproduce
Kotlin does not yet support 22 JDK target, falling back to Kotlin JVM_21 JVM target
> Inconsistent JVM-target compatibility detected for tasks 'compileJava' (17) and 'kspKotlin' (21).
Expected Behaviour
kspKotlin and compileJava should use the same language version automatically.
Actual Behaviour
kspKotlin and compileJava use different JVM target versions.
Environment Information