Configure Gradle JVM toolchain for Kotlin tasks
This commit is contained in:
parent
2a0ec0b2dd
commit
303e363adf
|
@ -98,22 +98,22 @@ pluginManager.withPlugin("kotlin") {
|
||||||
// Configure the Kotlin compiler if the 'mainToolchain' property is defined
|
// Configure the Kotlin compiler if the 'mainToolchain' property is defined
|
||||||
if (mainToolchainConfigured()) {
|
if (mainToolchainConfigured()) {
|
||||||
def mainLanguageVersion = mainToolchainLanguageVersion()
|
def mainLanguageVersion = mainToolchainLanguageVersion()
|
||||||
def compiler = javaToolchains.compilerFor {
|
|
||||||
languageVersion = mainLanguageVersion
|
|
||||||
}
|
|
||||||
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
|
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
|
||||||
def javaVersion = mainLanguageVersion.toString()
|
def javaVersion = mainLanguageVersion.toString()
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion.set(mainLanguageVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = javaVersion
|
jvmTarget = javaVersion
|
||||||
jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Compile the test classes with the same version, 'testToolchain' will override if defined
|
// Compile the test classes with the same version, 'testToolchain' will override if defined
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = javaVersion
|
jvmTarget = javaVersion
|
||||||
jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,11 +136,15 @@ pluginManager.withPlugin("kotlin") {
|
||||||
def compiler = javaToolchains.compilerFor {
|
def compiler = javaToolchains.compilerFor {
|
||||||
languageVersion = testLanguageVersion
|
languageVersion = testLanguageVersion
|
||||||
}
|
}
|
||||||
|
kotlin {
|
||||||
|
jvmToolchain {
|
||||||
|
languageVersion.set(testLanguageVersion)
|
||||||
|
}
|
||||||
|
}
|
||||||
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
|
// See https://kotlinlang.org/docs/gradle.html#attributes-specific-for-jvm
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
jvmTarget = testLanguageVersion.toString()
|
jvmTarget = testLanguageVersion.toString()
|
||||||
jdkHome = compiler.get().metadata.installationPath.asFile.absolutePath
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue