How to set in gradle and in maven to compile and use jvm with Java 1.8?
gradle
compileKotlin.sourceCompatibility = JavaVersion.VERSION_1_8
compileKotlin.targetCompatibility = JavaVersion.VERSION_1_8
compileKotlin.kotlinOptions.jvmTarget = "1.8"
is this ok?
There isn't a sourceCompatibility
or targetCompatibility
setting for the Kotlin compiler, you only need the jvmTarget
option, which you got right. You might want to set it for your tests as well. Overall, this is the config you need:
compileKotlin.kotlinOptions.jvmTarget = "1.8"
compileTestKotlin.kotlinOptions.jvmTarget = "1.8"
Alternatively, with different formatting:
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
Based on the documentation about using Kotlin with Gradle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With