robstoll
05/12/2023, 8:16 AMkotlin { jvmToolchain(11) }
I basically want to release my library with source/target compatibility for 1.8 but still be sure that the project compiles with 11. I also have tests which only make sense running under java 11, so switching to jvmToolChain(1.8) is not an option. Or I would need to have separate tasks which run the jdk 11 specific tests which seems neither a good option compared to the old way of using source/targetCompatibility where it just worked. Ideas?Vampire
05/12/2023, 8:18 AM*Compatibility
like expected. Maybe it works for Kotlin too.mbonnin
05/12/2023, 8:22 AMmbonnin
05/12/2023, 8:24 AMtasks.withType<Test>().configureEach {
javaLauncher.set(javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(11))
})
}
robstoll
05/12/2023, 8:54 AMrobstoll
05/12/2023, 8:56 AMTask :compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Error while evaluating property 'sourceCompatibility' of task ':compileJava'
> The new Java toolchain feature cannot be used at the project level in combination with source and/or target compatibility
mbonnin
05/12/2023, 8:58 AMproject.tasks.withType(JavaCompile::class.java).configureEach {
// Ensure "org.gradle.jvm.version" is set to "8" in Gradle metadata of jvm-only modules.
options.release.set(8)
}
robstoll
05/12/2023, 9:02 AM