How to set compileJava’ task ( 11) and ‘compileKotlin’ task (1.8) jvm target compatibility to the same Java version in build.gradle.kts?

You can set java version for java with

java {
    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

or alternatively:

java {
    toolchain.languageVersion.set(JavaLanguageVersion.of(11))
}

and for kotlin with:

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
    kotlinOptions {
        jvmTarget = "11"
    }
}

All samples are in gradle kotlin dsl.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)