Settings.gradle: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 14: Line 14:


=Example=
=Example=
==Single Project Build==
<syntaxhighlight lang='groovy'>
<syntaxhighlight lang='groovy'>
rootProject.name = 'myProject'
</syntaxhighlight>
==Multi-Project Build==
<syntaxhighlight lang='groovy'>
rootProject.name = 'myProject'
include 'project-a'
include 'project-b'
</syntaxhighlight>
</syntaxhighlight>

Revision as of 05:03, 22 October 2020

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'