api / org.gradle.api.tasks.incremental

Package org.gradle.api.tasks.incremental



interface IncrementalTaskInputs

Provides access to any input files that need to be processed by an incremental task.

An incremental task action is one that accepts a single IncrementalTaskInputs parameter. The task can then provide an action to execute for all input files that are out of date with respect to the previous execution of the task, and a separate action for all input files that have been removed since the previous execution.

 class IncrementalReverseTask extends DefaultTask { @InputDirectory def File inputDir @OutputDirectory def File outputDir @TaskAction void execute(IncrementalTaskInputs inputs) { if (!inputs.incremental) project.delete(outputDir.listFiles()) inputs.outOfDate { change -> def targetFile = project.file("$outputDir/${change.file.name}") targetFile.text = change.file.text.reverse() } inputs.removed { change -> def targetFile = project.file("$outputDir/${change.file.name}") if (targetFile.exists()) { targetFile.delete() } } } } 

In the case where Gradle is unable to determine which input files need to be reprocessed, then all of the input files will be reported as #outOfDate. Cases where this occurs include:

Note that this is a stateful API:


interface InputFileDetails

A change to an input file.