Creating a buildAll task in a composite project

I have a composite project, and I am trying to create a buildAll task, with Gradle 4.10.2.

So far I have this:

task buildAll {
  dependsOn gradle.includedBuilds*.task(':build')

however when executed this results in an error:

FAILURE: Build failed with an exception.

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

The project lib-foo is itself a composite build, as well as a multi-project build. The root project of the multi-project does not itself contain any code – only the subprojects do. When executing gradle build inside lib-foo it works fine and builds all of the subprojects. I can only assume that build directly in lib-foo does something “special” to loop through the subproject builds, but when called via buildAll this special sauce is not getting invoked.

I’ve tried creating an explicit build task inside lib-foo but haven’t gotten the syntax quite right there, it seems.