Propagating top-level tasks to all subprojects

Hi all…

I’m currently attempting a Gradle conversion using a structure based on that defined under “Structuring large projects”, so using that as an example:

https://docs.gradle.org/current/userguide/structuring_software_products.html

In that example, there’s an illustration of a task defined in the top-level build.gradle file which delegates to the various included build projects:

// This is an example of a lifecycle task that crosses build boundaries defined in the umbrella build.
tasks.register('checkFeatures') {
    group = 'verification'
    description = 'Run all feature tests'
    dependsOn(gradle.includedBuild('admin-feature').task(':config:check'))
    dependsOn(gradle.includedBuild('user-feature').task(':data:check'))
    dependsOn(gradle.includedBuild('user-feature').task(':table:check'))
}

My question is, how can I automate the list of dependsOn targets? This is manageable with one task delegating to three nested projects… not so much when doing this with multiple tasks, delegating to something on the order of 50 nested projects split across 2-3 included builds.

Ideally this would be as generic as “apply task X to all projects which support task X” (e.g. generate eclipse metadata for all projects with the “eclipse” plugin enabled), but I’m interested in any solutions that allow me to avoid repeating the entire list of projects dozens of times throughout the build scripts.

Simon.