The settings file is the entry point of every Gradle project.

gradle basic 3

The primary purpose of the settings file is to add subprojects to your build.

Gradle supports single and multi-project builds.

  • For single-project builds, the settings file is optional.

  • For multi-project builds, the settings file is mandatory and declares all subprojects.

Settings script

The settings file is a script. It is either a settings.gradle file written in Groovy or a settings.gradle.kts file in Kotlin.

The Groovy DSL and the Kotlin DSL are the only accepted languages for Gradle scripts.

The settings file is typically found in the root directory of the project.

Let’s take a look at an example and break it down:

settings.gradle.kts
rootProject.name = "root-project"   (1)

include("sub-project-a")            (2)
include("sub-project-b")
include("sub-project-c")
1 Define the project name.
2 Add subprojects.
settings.gradle
rootProject.name = 'root-project'   (1)

include('sub-project-a')            (2)
include('sub-project-b')
include('sub-project-c')
1 Define the project name.
2 Add subprojects.

1. Define the project name

The settings file defines your project name:

rootProject.name = "root-project"

There is only one root project per build.

2. Add subprojects

The settings file defines the structure of the project by including subprojects, if there are any:

include("app")
include("business-logic")
include("data-model")

Consult the Writing Settings File page to learn more.