I want to run Gradle with the default system JRE, in my case Java8.
And in the build I want to use a specific JDK 13 with the option.fork=true
compileJava {
options.encoding = 'UTF-8'
sourceCompatibility = 13
targetCompatibility = 13
options.compilerArgs << "-parameters"
options.compilerArgs << "--release" << "13"
options.compilerArgs << "--enable-preview"
options.fork = true
options.forkOptions.executable = "${projectDir}/tools/java/bin/javac.exe"
}
When I start gradle with the JRE 8, this fails with message:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Could not target platform: 'Java SE 13' using tool chain: 'JDK 8 (1.8)'.
But when I set the JAVA_HOME to the JDK 13, then it runs successfully.
Is there a way I can make this run, with the Gradle started with JRE8 but using the JDK13 for the build?
Frank