Until Gradle 7, I could use the following block in my build script to trigger Gradle to use a specific Java version independently of my runtime JDK (in this case, java11):
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
And thanks to this block, I could compile my project even with org.gradle.java.home
pointing at my jdk17 path.
After upgrading to Gradle 8.1.1, I get this error message:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\dev\workspace\foo\bar\build.gradle' line: 25
* What went wrong:
A problem occurred evaluating project ':baz'.
> The value for property 'languageVersion' is final and cannot be changed any further.
To make matters worse, the official Gradle documentation suggests to use my exact snippet to solve this problem, which obviously doesn't work.
I couldn't find any working code snippets apart from setting ´java.sourceCompatibility = JavaVersion.VERSION_11´, which doesn't allow me to compile without first changing org.gradle.java.home
to point at my jdk11.