Cleanup stale output files during execution (#2572)
We now keep a registry of all the outputs generated by Gradle which will be reset on each version change. If Gradle encounters an existing output file, then it will remove it if is not part of the registered outputs and owned by Gradle/the build. We do also not remove directories containing outputs from different tasks.
The check to delete the stale outputs happens now just before the task executes and not up-front as it did before.
The `build` directory and all delete targets of the `clean` task are registered as owned by Gradle and are considered safe to delete.
Currently, the set of recorded task output files is only growing if we do not change the Gradle version. In the future we can improve on this by also detecting that some directories where removed (e.g. by running a clean task) and reflect this in the registry.
28 Jul 17 dbf5680659900a5a0532ae2ae49677026390cf66
Add BuildOutputCleanup implementation
- Detect Gradle version changes by keeping a `built.bin` in the project cache dir
- Register a listener that triggers clean up at the end of the configuration phase
- The build output cleanup cache only invokes the deleter when the marker file is missing
- Provide a registry that plugins can contribute output files to
- In LifecycleBasePlugin (the base plugin), register the buildDir and clean task target files
- Use a build operation when cleaning stale output files
17 Jan 17 ebbe4a4f7fb200168f406bd8b92975865c82e14c