Can't figure out how to declare a dependency from the root project on a set of subprojects tasks

Can’t figure out how to create a dependency on a set of subprojects tasks

my build.gradle looks something like:

allprojects {
    apply plugin: 'idea'
  configure(srcProjects()) {
    apply plugin: 'java'
  task gatherArtifacts(dependsOn: uploadArchives) {

and my settings.gradle

include ':services:test1', ':api:test3' .......

when running gradle I get the error:

Cause: Could not find property 'uploadArchives' on root project 'ps-server'.

which makes sense since the root project doesn’t apply the ‘java’ plugin. But how do i do this?

Thanks, Charlie

task gatherArtifacts(dependsOn: srcProjects().uploadArchives) { ... }

If you are depending on tasks declared in the subprojects’ build scripts (which are, by default, evaluated after the parent project’s build script), you can defer the lookup by using a closure:

task gatherArtifacts(dependsOn: { srcProjects().uploadArchives }) { ... }

Thanks Peter! That did the trick!