Determining whether a task under test is out of date

(Schalk Cronjé) #1

When writing more complex tasks an useful test is to see whether a task is out of date if certain conditions are met. So far I have found no easy method that have a GradleRunner executed twice and then check the status.

Does anyone know if there a way I can check whether tasks are up to date without executing them?

(Stefan Wolf) #2

Hey Schalk,

why can’t you use the GradleRunner to run the task twice and then check the outcome? Here is an example how to do it in the ktlint plugin:


(Schalk Cronjé) #3

That is what I mentioned in my OP - I was looking for a way to do it, without running the task twice.

(Stefan Wolf) #4

Now I understand your question. There is currently no (public/easy) way to check if a task would be up-to-date without executing it twice.

The only good way to do this would be probably be to make it possible to calculate the build cache key for a given task. Then you could compare this build cache key to the one after you made a change.

Like I said above, we currently don’t have a public API (if any) for this.