I'm confused about <https://kotlinlang.org/docs/gr...
# gradle
m
I'm confused about https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support:
Copy code
When there is no explicit information about the jvmTarget value in the build script, its default value is null, and the compiler translates it to the default value 1.8. The targetCompatibility equals a current Gradle's JDK version
If the default value is
1.8
, how come
targetCompatibility
is Gradle's JDK? Is there a difference between
jvmTarget
and
targetCompatibility
?
t
JavaCompile
by default has
targetCompatibility
value set to current Gradle JDK version, while Kotlin
jvmTarget
is always
1.8
(but not with Gradle 8.+). So if you are running Gradle build with JDK 11 - your compiled Java and Kotlin classes will have different class version
m
I'm trying Gradle 8 at the moment
t
From Gradle 8.0 both Java and Kotlin uses default toolchain (by default same as Gradle JDK) and configure accordingly
targetCompatiblity
and
jvmTarget
values
m
I see . But looks like Android still forces java to 8 (but not Kotlin)
t
before Gradle 8 default toolchain is
null
leading to such difference
AGP has a bug, wait a sec
Actually bug is linked in the docs ) https://issuetracker.google.com/issues/260059413
m
Ah yes, perfetc!
I need a flow chart of jvmTargets 😅
Thanks for the insights!
t
with Gradle 8 and fix in AGP it should be straightforward 😅