Currently the recommended way to deal with different versions is JVM toolchains.
https://kotl.in/gradle/jvm/toolchain
The toolchains feature will properly configure Kotlin’s
jvmTarget
, Java’s
targetCompatibility
, choose the right Java stdlib, configure publishing attributes, etc. It doesn’t cause the Kotlin compiler to be executed on the old JDK, but configures the compilation to run against that JDK.
Manual configuration of
jvmTarget
is kinda a low-level configuration key, similar to Java’s
--target
, not
--release
. The Kotlin compiler has the argument
-Xjdk-release
that serves the same needs as
--release
of the Java compiler, however it’s not yet stabilized