Task that cleans the output of all its dependency tasks first?

In my build I just added a couple of grouping or aggregate tasks (a task who exists only to group the execution of other tasks). One of these tasks is named “generateSources”. Now, this is a multi-project build and “generateSources” is defined in the subprojects closure. Additionally each subproject can add additional dependencies to “generateSources”.

What I’d also like is to add a “regenerateSources” task. Ideally, I’d like to define this task to simply go through the dependencies defined on “generateSources” and perform a “clean” on each of its dependencies and then execute “generateSources”.

Is that in any way possible?

You might try the command line option ‘–rerun-tasks’. It should force the reexecution of tasks even with configured inputs/outputs.

Thanks for the reply Marco!

Was not aware of that option. I will give it a try. I assume --rerun-tasks invalidates all task caches? Not just the caches for the tasks I am running?

I guess it simply ignores the uptodate check for every tasks, it does not modify the cache. But i am not sure.

The doc states this: http://www.gradle.org/docs/current/userguide/gradle_command_line.html

--rerun-tasks
Specifies that any task optimization is ignored.