Gradle增量java编译导致完全重新编译

标签 gradle javacompiler

我只更改一个源文件并重新启动构建:

$ gradle jar
Incremental java compilation is an incubating feature.
:compileJava
Full recompilation is required because 'XXX.java' was changed.
Analysis took 0.241 secs.

我的gradle配置有:
compileJava {
  options.fork = true
  options.incremental = true
}

我希望 Gradle 只重新编译 XXX.java,这不是它应该做的吗?

最佳答案

我不知道该功能究竟是如何工作的,但根据 release notes for Gradle 2.1 ,

The current implementation is not able to fully analyze the impact of all changes to the source code in terms of identifying exactly which classes need to be recompiled. In such situations, all of the source will be recompiled in order to avoid inconsistent compilation results. Incremental Java compilation will improve over coming Gradle versions to be generally faster, and to invoke a full recompile in response to fewer types of changes.



这是几个版本之前的,但您没有指定您使用的是哪个版本。我想在某些情况下可能仍然需要重新编译几个类。

关于Gradle增量java编译导致完全重新编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37732179/

相关文章:

java - 依赖项未复制到 jar 中(在 Gradle 中)

android - Android Project如何具有不同的构建配置?

windows - 在 Eclipse 中创建新的 gradle 项目时无法选择完成

gradle - 如何获取rootProject.name并将其提供给应用程序,测试和分发?

java - 使用 "internal"JavaCompiler时如何设置bootclasspath

java - 这个 if 语句会抛出异常还是忽略它?

java - 如何将 Eclipse 指向另一个 ECJ(内部编译器)

java - Apache tomcat maven 插件在不存在的 Java 版本上编译

java - (JavaCompiler) 同时编译多个文件

kotlin - 在 kotlin 上使用模块构建 gradle 脚本