eygraber
11/10/2021, 7:24 PM> Task :buildSrc:compileKotlin
'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
My buildSrc build.gradle.kts
is in 🧵 and I believe I'm setting all of the Java and Kotlin targets correctly.eygraber
11/10/2021, 7:24 PM@file:Suppress("UnstableApiUsage")
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
google()
}
tasks.withType<JavaCompile> {
sourceCompatibility = libs.versions.jdk.get()
targetCompatibility = libs.versions.jdk.get()
}
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(libs.versions.jdk.get()))
}
}
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = libs.versions.jdk.get()
allWarningsAsErrors = true
}
}
dependencies {
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
implementation(libs.buildscript.android)
implementation(libs.buildscript.kotlin)
implementation(libs.buildscript.detekt)
implementation(libs.kotlinx.serialization)
implementation(libs.ejson)
}
tapchicoma
11/10/2021, 8:31 PMbuildSrc
to 8eygraber
11/10/2021, 9:23 PMpniederw
11/10/2021, 11:09 PMeygraber
11/11/2021, 12:04 AMeygraber
11/11/2021, 9:08 AMtapchicoma
11/11/2021, 9:34 AM'compileJava' task (current target is 11) and 'compileKotlin' task (current target is 1.8) jvm target compatibility should be set to the same Java version.
- this warning was introduced in the Kotlin 1.5.30 and does not relate to the linked issue above. Generally best solution would be to set toolchain to 8 java version. Also you could disable this warning at all: https://kotlinlang.org/docs/gradle.html#check-for-jvm-target-compatibilityeygraber
11/11/2021, 10:39 AMkotlinDslPluginOptions.jvmTarget.get()
? If so, is that something the plugin should do?tapchicoma
11/11/2021, 10:49 AMpniederw
11/11/2021, 12:14 PMbuildSrc/build.gradle.kts
):
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
I expect to be able to delete the above code after updating to Kotlin 1.6 (I don’t have any Java code in buildSrc
).