Why is compile avoidance disabled on my project


(Rob Reece) #1

I have a java project and when I edit a method implementation, all java files in the project compile. The below info level output is what I get when I edit a method in Z.java.

Task :core:Xproj:compileJava
Task ‘:core:Xproj:compileJava’ is not up-to-date because:
Input property ‘source’ file /… path removed …/Z.java has changed.
Created classpath snapshot for incremental compilation in 0.079 secs. 3528 duplicate classes found in classpath (see all with --debug).
Class dependency analysis for incremental compilation took 0.027 secs.
Full recompilation is required because ‘Z.java’ was changed. Analysis took 0.109 secs.

There shouldn’t be any reason a full recompilation is required since Z.java is not used by any other class. I understand there are some edits that can create full recompilations but I’m editing a v4 UUID String (changing one character) so that string shouldn’t be found in other class file. I also tried editing the name of a local var, same result. Where else can I look to help me understand the reason for the full recompilation?

Full disclosure - I have another open discussion at Annotation processor message doesn't tell me the jar file that has the AP.
I don’t think it is related to this issue but it might be. I’m happy to consolidate if that is best.


(Rob Reece) #2

The answer here is interesting. My class has a public final static String in it. Reading the Gradle source code, it looks like a Full recompile is invoked if your changed class simply contains any non-private, final, static constant. I don’t see any bytecode analysis to determine if other class files even have that constant at all, or any code that determines if the constant even changed. This happens in gradle 4.10.2 and the latest - 5.2.1.

Here is the relevant code
This code processes the constants in a class file.
This code triggers the full recompile when the Constant pool is not empty
This code filters the constant pool with “new constants”, but that method is invoked with a empty set for new constants (see here)