Hi! When using Kotlin with Gradle, should I define...
# gradle
h
Hi! When using Kotlin with Gradle, should I define
java.toolchain
or
kotlin.toolchain
in my
build.gradle.kts
or both? What is the difference between the two?
p
I use the following in my Kotlin JVM project for the Kotlin source code:
Copy code
kotlin {
        jvmToolchain(<My Javaversion>)
    }
If the project also has Java code you can use a toolchain for that.
Copy code
java{
    toolchain {
       anguageVersion.set(JavaLanguageVersion.of(<My Java version))
    }
}
Have you checked the Gradle documentation regarding toolchain? https://docs.gradle.org/current/userguide/toolchains.html
t
only one of them. It is up to you what to use exactly
h
@tapchicoma That was also my understanding. So in a pure Kotlin project, it doesn't actually matter?
t
yes, even in mixed Java/Kotlin it does not matter. DSL in Kotlin extension for now exists for convenience. In the future that may change for Kotlin-only projects.
p
Thanks for clarification.
h
Thanks for the quick answer!