To ensure that the jvm target compatibility for the 'compileJava' task (11) and the 'compileKotlin' task (1.8) are both set to the same Java version, you can add the following code to your build.gradle.kts file:
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "11"
}
tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
This code sets the jvm target compatibility for the 'compileKotlin' task to 11, and sets the sourceCompatibility and targetCompatibility for the 'compileJava' task to JavaVersion.VERSION_11, ensuring that both tasks are using the same Java version.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-07-01 08:11:06 +0000
Seen: 12 times
Last updated: Jul 01 '23
What are the typical approaches found in a Gradle build script?
How can we avoid the duplication of Kotlin class jetified-kotlin-stdlib-1.8.10 in Android (Java)?
Why can't IntelliJ IDEA detect the Kotlin multiplatform library?
What is the correlation between coroutines and the Kotlin Gradle Plugin?
What steps can be taken to increase the runtime of a debugger in NativeScript?