Consider a tool that reformats source files in-place. The format function is idempotent (a second run won’t change the file).
What I want to do now is to implement an incremental task that reformats source code only if necessary and otherwise reports UP-TO-DATE.
The problem:
Consider I make a change to file A
resulting in file #A
. Gradle detects that and my task runs the format tool on #A
generating A*
. Since A*
is now considered a changed input to the next run, the task will not report to be UP-TO-DATE.
How can I tell gradle to re-hash the formated file so it is not considered a dirty input for the next run?
This test case demonstrates the behavior I want.