PatrikTuri
(Patrik Turi)
September 18, 2019, 12:27am
1
Hello,
I have implemented a custom incremental task action by copying this guide:
https://docs.gradle.org/current/userguide/custom_tasks.html (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: https://gist.github.com/patrikturi/e7443ef79c74d1f4c42378dc3fe83868
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?
Cheers,
Stefan
PatrikTuri
(Patrik Turi)
September 18, 2019, 9:31am
3
Hi Stefan,
Thank you for your reply.
On a second look, indeed there is only one scenario that is not working incrementally:
Run “gradle convert”
Delete one of the output files (2.png)
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 https://docs.gradle.org/current/userguide/custom_tasks.html?_ga=2.103854016.196187290.1568620345-385499528.1554276773#sec:which_inputs_are_considered_out_of_date
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.
PatrikTuri
(Patrik Turi)
September 18, 2019, 10:48am
5
I understand, I think I can live with it.
I’m just used to GNU Make which does support this.
Stefan_Wolf
(Stefan Wolf)
September 18, 2019, 11:44am
6
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