How does Settings.include work for multi-project builds?

The documentation for Settings.include seems to indicate multi-project builds different from the way Gradle seems to work. The documentation reads:

Adds the given projects to the build. Each path in the supplied list is treated as the path of a project to add to the build. Note that these path are not file paths, but instead specify the location of the new project in the project heirarchy. As such, the supplied paths must use the ‘:’ character as separator. > >The last element of the supplied path is used as the project name. The supplied path is converted to a project directory relative to the root project directory. > >As an example, the path a:b adds a project with path :a:b, name b and project directory $rootDir/a/b.

However, using the following settings.groovy (generated with groovy init):

include ‘shared’

include ‘api’

include ‘services:webservice’

rootProject.name = ‘gradle-testing’

rootProject.children.each { project →

println “[$project.name, $project.path, $project.projectDir]”

}

The following output is recieved

[shared, :shared, C:\dv\sandbox\gradle-testing\shared]

[api, :api, C:\dv\sandbox\gradle-testing\api]

[services, :services, C:\dv\sandbox\gradle-testing\services]

Based upon the documentation, I would have expected to see this:

[shared, :shared, C:\dv\sandbox\gradle-testing\shared]

[api, :api, C:\dv\sandbox\gradle-testing\api]

[webservice, :services:webservice, C:\dv\sandbox\gradle-testing\services\webservice]

The key part of the documentation is this:

Note that these path are not file paths, but instead specify the location of the new project in the project heirarchy.

Basically this means that ‘include ‘services:webservice’’ creates a project named webservice which is a child of another project named services. In your example you are printing only the immediate children of the root project. Since webservice is a child of services it is not listed. However, running ‘gradle projects’ gives the following output:

Root project ‘gradle-testing’

±-- Project ‘:api’

±-- Project ‘:services’

|

-– Project ‘:services:webservice’

-– Project ‘:shared’

Alas, you are right. I realized this was probably the case on my commute home last night. :slight_smile:

Thanks!