not specifically kotlin related, how can I set source/targetCompatibility to a lower version (in my case 1.8) when I am using
kotlin { 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?
ah... it's only intellij which complains not gradle
robstoll
05/12/2023, 8:56 AM
ah no... must have been a glitch, now I get again:
Copy code
Task :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
m
mbonnin
05/12/2023, 8:58 AM
I do this:
Copy code
project.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)
}