Resetting the UP-TO-DATE property of gradle tasks?

Try to run your build with -C rebuild that rebuilds Gradle's cache.

In newer versions of Gradle, use --rerun-tasks


If you want just a single task to always run, you can set the outputs property inside of the task.

outputs.upToDateWhen { false }

Please be aware that if your task does not have any defined file inputs, Gradle may skip the task, even when using the above code. For example, in a Zip or Copy task there needs to be at least one file provided in the configuration phase of the task definition.


You can use cleanTaskname

Let's say you have

:someproject:sometask1 UP-TO-DATE
:someproject:sometask2 UP-TO-DATE
:someproject:sometask3 UP-TO-DATE

And you want to force let's say sometask2 to run again you can

someproject:cleanSometask2

before you run the task that runs it all.

Apparently in gradle, every task that understands UP-TO-DATE also understand how to clean itself.

Tags:

Groovy

Gradle