According to the Gradle docs,
finalizer tasks are not executed if the finalized task didn't do any work, for example if it is considered up to date
However, as per this question on StackOverflow, the following test case does not conform to the documented behavior:
task taskY << { println 'taskY' } task taskX { outputs.upToDateWhen { true } finalizedBy taskY doLast { println 'taskX' } }
When
gradle taskX
or
./gradlew taskX
are run (at least for Gradle 2.3), the following output is produced, clearly indicating that
taskX
is skipped due to being up-to-date, yet
taskY
still runs.
:taskX UP-TO-DATE :taskY taskY