InputChanges always non-incremental in custom incremental task action

I have implemented a custom incremental task action by copying this guide: (example 6.)

However, when I run it, it always prints “Executing non-incrementally” and lists all files as changed even if only one of them changed in fact.

How can I get it to print “‘Executing incrementally’” and process only the files that are actually updated/changed?

Here is my code:

Hi Patrik,

I tried your build file and it seems to work for me. The first time the task runs I get:

$> gradle convert

> Task :convert
Executing non-incrementally

Then I add a file in the images directory and run the task again:

$> gradle convert

> Task :convert
Executing incrementally
Updating: some.png

Am I doing something differently to what you are doing?


Hi Stefan,
Thank you for your reply.

On a second look, indeed there is only one scenario that is not working incrementally:

  1. Run “gradle convert”
  2. Delete one of the output files (2.png)
  3. Run “gradle convert” again, it will update all files instead of only 2.png

Console output is this for both points 1) and 3):

$ gradle convert

> Task :convert
Executing non-incrementally
Updating: 1.png
Updating: 2.png
Updating: 3.png

If an output file changes, then Gradle will do a full rebuild, see

The reason for this is that only the task action should be changing the outputs of the task. If other process manipulates the outputs, then Gradle assumes that the task needs to re-run to get back to a clean state.

I understand, I think I can live with it.
I’m just used to GNU Make which does support this.

GNU Make knows about the relation between source files and output files, since that is what you declare in the Makefile. Since for Gradle the relationship doesn’t have to be 1:1 and we currently don’t provide a way to model the information, changes to output files are not supported.

1 Like