I'm trying to build Kotest but I'm getting some er...
# kotest
w
I'm trying to build Kotest but I'm getting some errors about
Unknown Kotlin JVM target: 20
. I suppose it's because I'm running Gradle with JDK 20 and the build is not using toolchains. Should I build Kotest with JDK8 (that's the jdk used in CI too) or are some more recent JDK versions supported too? Would it make sense to use toolchains and allow running the build with any jdk, or there are some issues that prevent that (I don't know how Kotlin Multiplatform and Toolchains play together)?
c
isnt that a problem with the kotlin plugin that applies to all kotlin projects? jdk 19 should work iirc.
w
Right, there's https://youtrack.jetbrains.com/issue/KT-57669/Add-Java-20-to-JvmTarget. Although JDK20 works fine for my projects, I suppose it's because I set all targets explicitly blob thinking fast
c
oh nice. i did not know that thats a workaround.
w
I think it's less of a workaround and more of a good practice anyway — defaulting compile target to JDK running the build is pretty iffy, and using JDK 8 is at best a performance hit. You should be able to set up the build to work with JDK 20, tasks to use JDK 17 (or even some more recent one but 17 works for sure. I think Detekt had some issues with recent JDKs in the past) and just to set up Kotlin compiler to spit out Java 8 bytecode. Ymmv of course, a strong argument for always using recent JDKs (so also on CI) is issues like https://youtrack.jetbrains.com/issue/KT-55831/Kapt-Cant-find-annotation-processor-class-dagger.internal.codegen.ComponentProcessor-Metaspace where memory usage went from gigabytes to 150MB just by switching to JDK19
c
sure, I set jvmtarget in all my projects. but when a jdk is new like jdk 20 I keep using 19 for some time. jdk 8 is totally out of the question 🙂
e
Awesome! 🚀