Severe up-to-date check bug in case of deleted files

(Jörn Huxhorn) #1


Gradle up-to-date check does not take into account deleted files. This has been confirmed for Gradle 1.3 with ‘java’ and ‘groovy’ plugins.

Steps to reproduce:

  1. Create a build.gradle containing
apply plugin: 'java'
  1. Create the directories src/main/java 3. Create a file src/main/java/ containing
public class Foo {}
  1. Execute
gradle build
  • compileJava will be executed. 5. Execute
gradle build
  • compileJava will be UP-TO-DATE. 6. Delete the file src/main/java/ 7. Execute
gradle build
  • compileJava will still be UP-TO-DATE.

Result Because of this, the deleted class will still be available in both build/classes/main and the created jar in build/lib.

(René Groeschke) #2

In your scenario, you delete all source files. The problem is that gradle marks the compile task as up-to-date as soon as sources is empty. If this is a problem in your build this workaround might help:

 compileJava.dependsOn cleanCompileJava

(Jörn Huxhorn) #3

But isn’t this a quite evil bug nevertheless?

If compileJava was previously involved in the creation of classes and/or jar then those tasks need to be considered changed if compileJava won’t be executed anymore.

We had the situation that we renamed the whole src/main/java folder to src/main/groovy. We also did some refactoring that resulted in the deletion of some classes. But all previously compiled classes were still kept in both the classes and lib resulting in utter chaos. The local build was still working (until performing a mavenesque manual ‘clean’) but our CI server that always performs a clean build was puking because one of the deleted classes was still used in a test…

I think that an empty directory shouldn’t be considered UP-TO-DATE but something else, like e.g. SKIPPED, thus resulting in a refresh of dependent tasks.

(René Groeschke) #4

Hey Huxi,

It’s defnitely a bug you’re running into. The workaround is just … well a workaround ;-). We’ll export this thread here to our jira.

(Jörn Huxhorn) #5

Thanks, that’s all I wanted to hear. :wink:

(René Groeschke) #6

Thank you for the report. I’m glad, that we could make you happy that easily just before the weekend starts :wink:

best regards, René