After upgrading to from Gradle 6.7.1 to Gradle 7.4, the following error occurs:
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':example-project:compileJava'.
> Failed to query the value of extension 'example-extension' property 'enabled'.
> Failed to calculate the value of task ':example-project:compileJava' property 'javaCompiler'.
> No compatible toolchains found for request filter: {languageVersion=11, vendor=any, implementation=vendor-specific} (auto-detect true, auto-download false)
Add this to build.gradle
:
java {
toolchain {
implementation = JvmImplementation.J9
}
}
It turned out that the JDK I used was implemented with J9.
At the time of writing, Gradle ignores JDK implemented with J9 unless explicitly set to use it.
This appears to be a bug:
https://github.com/gradle/gradle/issues/16897#issuecomment-823272229
To check whether your JDK is implemented in J9 or not, run
path/to/your/jdk/bin/java -version
The output will look something like this:
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9)
Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.24.0, JRE 11 Linux amd64-64-Bit 20210120_821 (JIT enabled, AOT enabled)
OpenJ9 - 345e1b09e
OMR - 741e94ea8
JCL - 0a86953833 based on jdk-11.0.10+9)