Gradle builds are fast because Gradle supports incremental tasks. This means Gradle can determine if input or output of task has changed, before running the task. If nothing has changed a task is marked a up-to-date and the task is not executed, otherwise the task is executed. If we want execute a task even if it is up-to-date we must use the command line option
In the following example we run the
assemble task for a simple Java project, and we see all tasks are executed. When we invoke the
assemble task again we see the tasks are all up-to-date:
$ gradle assemble :compileJava :processResources :classes :jar :assemble BUILD SUCCESSFUL Total time: 1.765 secs $ gradle assemble :compileJava UP-TO-DATE :processResources UP-TO-DATE :classes UP-TO-DATE :jar UP-TO-DATE :assemble UP-TO-DATE BUILD SUCCESSFUL Total time: 0.715 secs $
To run all tasks without an up-to-date check we use the option
$ gradle --rerun-tasks assemble :compileJava :processResources :classes :jar :assemble BUILD SUCCESSFUL Total time: 1.037 secs $
Written with Gradle 3.2.1.