简体   繁体   English

我如何确定构建中使用了哪个版本的 JAVAC Gradle?

[英]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.我需要确定哪个版本的 javac gradle 用于执行任务。 Is there a way that I can make it print the version or path of javac used?有没有办法让它打印使用的javac的版本或路径?

I'm using Gradle 5.2.1 on MacOS我在 MacOS 上使用 Gradle 5.2.1

Gradle is not actually using javac (the executable). Gradle 实际上并未使用javac (可执行文件)。 Rather, it uses the compiler classes programmatically.相反,它以编程方式使用编译器类。

By default, Gradle will use the classes from the JDK you use for running Gradle.默认情况下,Gradle 将使用 JDK 中的类来运行 Gradle。 You can check the version by running gradlew --version .您可以通过运行gradlew --version检查版本。 This also goes for the Javadoc and JavaExec task (and similar Java-related tasks and methods).这也适用于JavadocJavaExec任务(以及类似的与 Java 相关的任务和方法)。

It is possible to fork the these tasks and use a different JDK than for running Gradle.可以分叉这些任务并使用与运行 Gradle 不同的 JDK。 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).如果这不是您的项目并且您需要确定,请搜索“forkOptions”(旧且复杂的方法)和“工具链”(新且简单的方法)。

I am not aware of a way to make Gradle print the version of Java it will use for a given Java-related task.我不知道有一种方法可以让 Gradle 打印 Java 的版本,它将用于给定的 Java 相关任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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