简体   繁体   中英

How do I know for sure which version of JAVAC Gradle used in a build?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM