Hello,
We are migrating from Gradle 7.5 to 8.0.
We have a build.gradle file with this snippet of configuration to execute the Java tests:
...
...
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.fork = true
options.forkOptions.executable = System.getenv('JAVA_HOME') + '/bin/javac'
}
tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
executable = System.getenv('JAVA_HOME') + '/bin/java'
}
...
...
In 7.5 version it works ok but when we run it on a Windows environment with Gradle 8.0 we obtain this error:
> Task :Application_Name-test:compileTestJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':Application_Name-test:compileTestJava'.
> Error while evaluating property 'javaCompiler' of task ':Application_Name-test:compileTestJava'.
> Failed to calculate the value of task ':Application_Name-test:compileTestJava' property 'javaCompiler'.
> The configured executable does not exist (C:\Program Files\OpenJDK\openjdk-17.0.5.8\jdk-17.0.5+8\bin\javac)
If we add the executable extension to the file name everything works on Windows:
...
...
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.fork = true
options.forkOptions.executable = System.getenv('JAVA_HOME') + '/bin/javac.exe'
}
tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
executable = System.getenv('JAVA_HOME') + '/bin/java.exe'
}
...
...
The problem is that it must work also in Linux environments.
Any idea about why it work on 7.5 but not in 8.0, and how to solve it?