6

I change only one source file and relaunch the build:

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

My gradle configuration has:

compileJava {
  options.fork = true
  options.incremental = true
}

I would expect Gradle to only recompile XXX.java, is it not what it should do?

The Alchemist
  • 3,397
  • 21
  • 22
benji
  • 2,331
  • 6
  • 33
  • 62

2 Answers2

0

I don't know exactly how the feature works, but according to the 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.

This was several versions ago, but you didn't specify which version you're using. I suppose that it may still be necessary to recompile several classes, under some circumstances.

Jolta
  • 2,620
  • 1
  • 29
  • 42
  • Thank you, I'm using Gradle 2.12. Right now I'm wondering if it is ever able to avoid a full recompilation. – benji Jun 09 '16 at 17:30
0

You probably have a non-private constant in that java file.

Check this issue.

Sergiy
  • 221
  • 3
  • 11