Rutime change detection of task input values

Hi,

I would like to test whether I can trigger the re-execution of a task in continuous mode (-t) by changing at runtime the value of input properties as discussed here.

For that I’ve created a dummy task (see Gist below) that has 2 input properties: an Integer (@Input) and a File (@InputFile). I have created a count-down thread that modifies the value of the task integer every second, and after 5 seconds it deletes the temporary file. I had to add the @InputFile property to keep alive the gradle daemon, otherwise if finished after the first execution.

I can see that when the inputFile is deleted the task is re-executed. However, while the event listener does modify the input value at runtime, gradle does not pick up the change and therefore does not re-execute.

$ gradle dummy -i -t

> Configure project :
...
> Task :dummy
Task ':dummy' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Hello Dummy : 5
:dummy (Thread[Task worker for ':',5,main]) completed. Took 0.008 secs.

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed

Waiting for changes to input files of tasks... (ctrl-d to exit)
reducing
reducing
reducing
reducing
reducing
deleting tmp file
deleted: /var/folders/1x/wb_n_j915dz12rbjl0b3w98r0000gn/T/hasfdasdfi9051474707502581178ho
Change detected, executing build...

Starting Build

> Configure project :
...
> Task :dummy
Task ':dummy' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Hello Dummy : 5
:dummy (Thread[Task worker for ':',5,main]) completed. Took 0.006 secs.

BUILD SUCCESSFUL in 0s
1 actionable task: 1 executed

Waiting for changes to input files of tasks... (ctrl-d to exit)
reducing
reducing
reducing
reducing
reducing
deleting tmp file
deleted: /var/folders/1x/wb_n_j915dz12rbjl0b3w98r0000gn/T/hasfdasdfi2977562675956406067ho
Change detected, executing build...


I am trying to figure out how can I enable the detection of changes to the not file-based property value. Any ideas?

Hi Betty,

Gradle is currently only looking for file changes to trigger a rebuild, not for property value changes. Normally, a property value can’t be modified from outside the configuration script, that’s why we don’t look for changes there.

What is your use case for doing continuous build based on property changes?

Cheers,
Stefan