We have encountered the following case of the build producing bad output, steps to reproduce are;
run gradle clean 2) Add a new class, the compiled class will end up in the build directory 3) Delete the source class
Delete the project’s root .gradle folder
Do another build. The class file will remain in the build directory.
If one were to produce a jar from this build, it would contain the “bad” class. As far as I can see the 2nd build completes normally and sees that it has no record of the compile task running so executes it.
Any ideas on the root cause for this? My guess is that in normal circumstances, when it has a view of what the output was last time, it is able to work out that the deleted class is no longer in the input so should not be in the output (or some variation on this).
It seems like the correct behaviour should be to treat every project build as untrusted if it runs and finds that .gradle does not exist but a build dir does. I don’t know enough about how gradle caches work to be sure on that though.