ALU

incremental tasks

Gradle Goodness: Rerun Incremental Tasks at Specific Intervals

One of the most important features in Gradle is the support for incremental tasks. Incremental tasks have input and output properties that can be checked by Gradle. When the values of the properties haven’t changed, then the task can be marked as up to date by Gradle and it is not executed. This makes a build much faster. Input and output properties can be files, directories, or plain object values. We can set a task input property with a date or date/time value to define when a task is up to date for a specific period. As long as the value of the input property hasn’t changed (and of course, also the other input and output property values), Gradle will not rerun task and mark it as up to date. This is useful, for example, if a long-running task (e.g. large integration test suite) only needs to run once a day or another period.

In the following example, in the Gradle build file, we define a new task Broadcast that will get content from a remote URL and save it in a file. In our case, we want to save the latest messages from SDKMAN!. If you don’t know SKDMAN!, you should check it out!. The Broadcast task has an incremental task output property, which is the output file of the task:

Original Link