I need to be sure of which version of javac gradle used for executing a task. Is there a way that I can make it print the version or path of javac used?
I'm using Gradle 5.2.1 on MacOS
Gradle is not actually using javac
(the executable). Rather, it uses the compiler classes programmatically.
By default, Gradle will use the classes from the JDK you use for running Gradle. You can check the version by running gradlew --version
. This also goes for the Javadoc
and JavaExec
task (and similar Java-related tasks and methods).
It is possible to fork the these tasks and use a different JDK than for running Gradle. But this has to be configured in the build script and if you did that, then you probably also know already what you made them use. If this is not your project and you need to be sure, search for "forkOptions" (old and complicated way to do it) and "toolchain" (new and easy way).
I am not aware of a way to make Gradle print the version of Java it will use for a given Java-related task.