Use JVM toolchain instead of Kotlin jvmTarget

This [new Gradle feature](https://kotlinlang.org/docs/gradle-configure-project.html#gradle-java-toolchains-support) makes Gradle install the respective JDK/JRE instead of just using whatever JVM Gradle itself happens to run under. On my machine, that would be JVM 11, which leads to errors like `class file has wrong version 61.0, should be 55.0` when Dagger-generated Java files (like factories) try to interact with Kotlin-compiled classes.
The `compilerOptions.jvmTarget` is then implied.
This commit is contained in:
Philipp Keck 2023-01-29 11:53:19 +01:00
parent 189a306df4
commit 01db3ef36d

View file

@ -53,8 +53,13 @@ tasks.test {
}
}
kotlin {
jvmToolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "17"
kotlinOptions.allWarningsAsErrors = true
kotlinOptions.freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
}