Multiproject build with shared components and pre-arranged layout

I’ve been wrestling with a problem related to multiproject builds. I have an existing source tree which looks somewhat like this:

.
|-- firstapplication
|
 |-- build
|
 |
 '-- settings.gradle
|
 |-- firstcomponent
|
 '-- secondcomponent
|-- secondapplication
'-- shared
    '-- firstsharedcomponent

i.e. there is some shared code that each application wants to use, and which should be included in that application’s build. I want the build scripts for each application to live in a logical location for that application - here the example is firstapplication/build/. I tried a settings.gradle like this:

rootProject.projectDir = new File( $srcroot )
  include 'shared:firstsharedcomponent', 'firstapplication:firstcomponent', 'firstapplication:secondcomponent'

where $srcroot points to the directory that contains firstapplication.

However, if in the firstapplication/build directory I do:

gradle projects

I get:

:projects
  ------------------------------------------------------------
Root project
------------------------------------------------------------
  Root project 'build'
No sub-projects
  To see a list of the tasks of a project, run gradle <project-path>:tasks
For example, try running gradle :tasks
  BUILD SUCCESSFUL

I expected this to find the projects starting from the rootdir, but obviously it doesn’t. What am I doing wrong?