Composite builds, create generic task to target All tasks in included builds


I have started playing with composite build in preparation for migration from multi-project builds.

I was playing with the idea of having a task in my composed build that can address all tasks in the included builds.

tasks.addRule("Pattern: <taskname>All") {String taskName ->
	if(taskName.endsWith("All")) {
		task(taskName) {
			dependsOn(gradle.includedBuilds*.task(":" + (taskName - 'All')))

basically by running:

gradlew buildAll

the task build is run against all included builds

Few questions:

  • Is there a more elegant solution to do this?
  • If I need to pass a parameter to the task in the included build (i.e. gradlew dependenciesAll --configuration implementation) how could I do it?