Task with path 'build' not found in root project

I have a multiproject and after the last subproject is built, I’d like to process all jars.
Therefore I created a task in the root-project:

task install(dependsOn: "build", type: Copy) {
    doLast {
        println "exec install task"

Upon calling “./gradlew install” in the root directory, I’m facing this error:

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':install'.
> Task with path 'build' not found in root project 'foo'.

However, calling “./gradlew tasks” shows me these tasks:


All tasks runnable from root project

Build tasks
assemble - Assembles the outputs of this project.
build - Assembles and tests this project.

How can I achieve the desired functionality?

I’m having the same issue, but trying to depend on “uninstallAll”. Any solution for this?