Fine Tuning the Project Layout
A multi-project build is a build where you build more than one project during a single execution of Gradle. You have to declare the projects taking part in the multi-project build in the settings file.
Multi-project builds are always represented by a tree with a single root.
Each element in the tree represents a project.
A project has a path which denotes the position of the project in the multi-project build tree.
In most cases the project path is consistent with the physical location of the project in the file system.
However, this behavior is configurable. The project tree is created in the
The location of the settings file is also the location of the root project.
In the settings file you can use the
include method to build the project tree.
include 'project1', 'project2:child', 'project3:child1'
include("project1", "project2:child", "project3:child1")
include method takes project paths as arguments.
The project path is assumed to be equal to the relative physical file system path.
For example, a path 'services:api' is mapped by default to a folder 'services/api' (relative from the project root).
You only need to specify the leaves of the tree.
This means that the inclusion of the path 'services:hotels:api' will result in creating 3 projects: 'services', 'services:hotels' and 'services:hotels:api'.
More examples of how to work with the project path can be found in the DSL documentation of Settings.include(java.lang.String).
The multi-project tree created in the settings file is made up of so called project descriptors. You can modify these descriptors in the settings file at any time. To access a descriptor you can do:
println rootProject.name println project(':project-a').name
Using this descriptor you can change the name, project directory and build file of a project.
rootProject.name = 'main' project(':project-a').projectDir = file('../my-project-a') project(':project-a').buildFileName = 'project-a.gradle'
rootProject.name = "main" project(":project-a").projectDir = file("../my-project-a") project(":project-a").buildFileName = "project-a.gradle"
Look at the ProjectDescriptor class in the API documentation for more information.