Incremental build deletes classes and then does not recompile them

I’m experiencing a strange sort of behavior that smells a little like a bug in the incremental build logic for Gradle, but perhaps it’s a problem on our end.

My setup is:

  • Gradle 4.7
  • Java 8
  • Multi-project build
  • Project A’s default configuration declared as a compile dependency for Project B
  • Project B’s default configuration declared as a compile dependency for Project C

When I make changes in the interface of one of the classes in Project A and then build all my modules, I can see in the debug output that the classes in Project C’s classes directory that use classes in Project A are being deleted, as one might expect, but then this message is shown: "20:40:27.857 [INFO] [org.gradle.api.internal.tasks.compile.incremental.SelectiveCompiler] None of the classes needs to be compiled! "

I end up with an empty classes directory and therefore a less than functional jar file. Strangely, this seems to occur only when Project C is just a bare-bones project without much of its own functionality, but I don’t quite understand why.

Does this ring a bell with anyone?



The classes in Project C shouldn’t be deleted if there was nothing to compile. Could you provide a reproducible example project?

I knew you were going to ask that. :slight_smile: I can try to tease out a small example.

Finally I was able to get back to this and I can report, somewhat embarrassingly, that this was a simple case-sensitivity issue. The removal of the class files was appropriate as one of the classes referenced in these files changed. The files were not being recompiled because the stub of a project that was created by one of our internal tools, mistakenly capitalized the directory in which the Java classes were created, which made it not match the package name for those classes. When the incremental compiler converted the package name into a directory name to determine if anything needed to be compiled, it found nothing in that (non-existent) lower-case directory and therefore determined there was nothing to compile. IntelliJ was, of course, screaming at me about this mismatch between package name and directory name when I looked at the file. Still took me longer than I like to admit to recognize this was the actual cause of the build problem.

I am somewhat surprised that the command-line compile didn’t have similar complaints, but I that seems like a javac thing, not a gradle thing.



I think our incremental compiler could detect this and warn/fail. Would you mind opening an issue?

Issue filed: