Settings.gradle
Jump to navigation
Jump to search
External
Internal
Overview
The settings file defines which projects are taking part in a multi-project build, and it is optional for a single-project build. It can also be used to add libraries to the build scripts classpath. The default name is settings.gradle. The settings file is referred to as an Gradle settings script. The file is executed during the initialization phase. During execution, property access and method calls are delegated to the Settings delegate.
How Gradle Looks for a Settings File
If the gradle command is executed from a directory with no settings.gradle file, Gradle looks for the file in the following way:
- It looks for settings.gradle in the parent directories. If not found, the project is executed as a single project build.
- If a settings.gradle file is found, Gradle checks if the current project is part of the multi-project hierarchy defined in that file. If it is, the multi-project build is executed, otherwise the build is executed as a single project build.
Example
Single Project Build
rootProject.name = 'myProject'
Multi-Project Build
rootProject.name = 'myProject'
include 'project-a'
include 'project-b'
Non-Standard Project Structure
rootProject.name = 'myProject'
include 'project-a'
project(':project-a').projectDir = file('something/project-a')