# In-place source code transformation and up-to-date check

**URL:** <https://discuss.gradle.org/t/in-place-source-code-transformation-and-up-to-date-check/12785>\
**Category:** Help/Discuss\
**Created:** [November 16, 2015, 9:33pm UTC](https://discuss.gradle.org/t/in-place-source-code-transformation-and-up-to-date-check/12785 "2015-11-16T21:33:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sherter](https://avatars.discourse-cdn.com/v4/letter/s/779978/32.png) [@sherter](https://discuss.gradle.org/u/sherter)\
**Post date:** [November 16, 2015, 9:33pm UTC](https://discuss.gradle.org/t/in-place-source-code-transformation-and-up-to-date-check/12785/1 "2015-11-16T21:33:23Z")

</div>

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](https://github.com/sherter/google-java-format-gradle-plugin/blob/a6516a2f228405e29cecb06d4806bf525f1a0717/src/test/groovy/com/github/sherter/googlejavaformatgradleplugin/GoogleJavaFormatTaskTest.groovy#L36) demonstrates the behavior I want.
