api / org.gradle.api.initialization / Settings


interface Settings : PluginAware

Declares the configuration required to instantiate and configure the hierarchy of instances which are to participate in a build.

There is a one-to-one correspondence between a Settings instance and a {@value * #DEFAULT_SETTINGS_FILE} settings file. Before Gradle assembles the projects for a build, it creates a Settings instance and executes the settings file against it.

Assembling a Multi-Project Build

One of the purposes of the Settings object is to allow you to declare the projects which are to be included in the build. You add projects to the build using the #include(String...) method. There is always a root project included in a build. It is added automatically when the Settings object is created. The root project's name defaults to the name of the directory containing the settings file. The root project's project directory defaults to the directory containing the settings file.

When a project is included in the build, a ProjectDescriptor is created. You can use this descriptor to change the default values for several properties of the project.

Using Settings in a Settings File Dynamic Properties

In addition to the properties of this interface, the Settings object makes some additional read-only properties available to the settings script. This includes properties from the following sources:



static val DEFAULT_SETTINGS_FILE: String

The default name for the settings file.



abstract fun buildCache(action: Action<in BuildCacheConfiguration>): Unit

Configures build cache.


abstract fun enableFeaturePreview(name: String): Unit

Enables a feature preview by name.


abstract fun findProject(path: String): ProjectDescriptor

Returns the project with the given path.

abstract fun findProject(projectDir: File): ProjectDescriptor

Returns the project with the given project directory.


abstract fun getBuildCache(): BuildCacheConfiguration

Returns the build cache configuration.


abstract fun getBuildscript(): ScriptHandler

Returns the build script handler for settings. You can use this handler to query details about the build script for settings, and manage the classpath used to compile and execute the settings script.


abstract fun getGradle(): Gradle

Returns the Gradle instance for the current build.


abstract fun getPluginManagement(): PluginManagementSpec

Returns the plugin management configuration.


abstract fun getRootDir(): File

Returns the root directory of the build. The root directory is the project directory of the root project.


abstract fun getRootProject(): ProjectDescriptor

Returns the root project of the build.


abstract fun getSettings(): Settings

Returns this settings object.


abstract fun getSettingsDir(): File

Returns the settings directory of the build. The settings directory is the directory containing the settings file.


abstract fun getSourceControl(): SourceControl

Returns the source control configuration.


abstract fun getStartParameter(): StartParameter

Returns the set of parameters used to invoke this instance of Gradle.


abstract fun include(vararg projectPaths: String): Unit

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 hierarchy. As such, the supplied paths must use the ':' character as separator (and NOT '/').

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. The project directory can be altered by changing the 'projectDir' property after the project has been included (see ProjectDescriptor#setProjectDir(File))

As an example, the path a:b adds a project with path :a:b, name b and project directory $rootDir/a/b. It also adds the a project with path :a, name a and project directory $rootDir/a, if it does not exist already.

Some common examples of using the project path are:

 // include two projects, 'foo' and 'foo:bar' // directories are inferred by replacing ':' with '/' include 'foo:bar' // include one project whose project dir does not match the logical project path include 'baz' project(':baz').projectDir = file('foo/baz') // include many projects whose project dirs do not match the logical project paths file('subprojects').eachDir { dir -> include dir.name project(":${dir.name}").projectDir = dir } 


abstract fun includeBuild(rootProject: Any): Unit

Includes a build at the specified path to the composite build.

abstract fun includeBuild(rootProject: Any, configuration: Action<ConfigurableIncludedBuild>): Unit

Includes a build at the specified path to the composite build, with the supplied configuration.


abstract fun includeFlat(vararg projectNames: String): Unit

Adds the given projects to the build. Each name in the supplied list is treated as the name of a project to add to the build.

The supplied name is converted to a project directory relative to the parent directory of the root project directory.

As an example, the name a add a project with path :a, name a and project directory $rootDir/../a.


abstract fun pluginManagement(pluginManagementSpec: Action<in PluginManagementSpec>): Unit

Configures plugin management.


abstract fun project(path: String): ProjectDescriptor

Returns the project with the given path.

abstract fun project(projectDir: File): ProjectDescriptor

Returns the project with the given project directory.


abstract fun sourceControl(configuration: Action<in SourceControl>): Unit

Configures source control.

Inherited Functions


abstract fun apply(closure: Closure<Any>): Unit
abstract fun apply(action: Action<in ObjectConfigurationAction>): Unit

Applies zero or more plugins or scripts.

The given closure is used to configure an ObjectConfigurationAction, which “builds” the plugin application.

This method differs from #apply(java.util.Map) in that it allows methods of the configuration action to be invoked more than once.

abstract fun apply(options: MutableMap<String, *>): Unit

Applies a plugin or script, using the given options provided as a map. Does nothing if the plugin has already been applied.

The given map is applied as a series of method calls to a newly created ObjectConfigurationAction. That is, each key in the map is expected to be the name of a method ObjectConfigurationAction and the value to be compatible arguments to that method.

The following options are available:

  • from: A script to apply. Accepts any path supported by org.gradle.api.Project#uri(Object).
  • plugin: The id or implementation class of the plugin to apply.
  • to: The target delegate object or objects. The default is this plugin aware object. Use this to configure objects other than this object.


abstract fun getPluginManager(): PluginManager

The plugin manager for this plugin aware object.


abstract fun getPlugins(): PluginContainer

The container of plugins that have been applied to this object.

While not deprecated, it is preferred to use the methods of this interface or the plugin manager than use the plugin container.

Use one of the 'apply' methods on this interface or on the plugin manager to apply plugins instead of applying via the plugin container.

Use PluginManager#hasPlugin(String) or similar to query for the application of plugins instead of doing so via the plugin container.

Extension Functions


fun <T : Plugin<Settings>> Settings.apply(): Unit

Applies the plugin of the given type T. Does nothing if the plugin has already been applied.


operator fun Settings.provideDelegate(any: Any?, property: KProperty<*>): PropertyDelegate

Locates a property on Settings.



abstract class SettingsScriptApi : Settings

Standard implementation of the API exposed to all types of Settings scripts, precompiled and otherwise.