Settings

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 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:

  • Defined in the {@value org.gradle.api.Project#GRADLE_PROPERTIES} file located in the settings directory of the build.
  • Defined the {@value org.gradle.api.Project#GRADLE_PROPERTIES} file located in the user's .gradle directory.
  • Provided on the command-line using the -P option.

Properties

Link copied to clipboard
val DEFAULT_SETTINGS_FILE: String = "settings.gradle"
The default name for the settings file.
Link copied to clipboard

The extra properties extension in this object's extension container.

Functions

Link copied to clipboard
abstract fun apply(closure: Closure)
Link copied to clipboard
inline fun <T : Plugin<Settings>> Settings.apply()
inline fun <T : Plugin<*>> PluginAware.apply()

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

inline fun PluginAware.apply(vararg options: Pair<String, Any?>)

Kotlin extension function for org.gradle.api.plugins.PluginAware.apply.

fun PluginAware.apply(from: Any? = null, plugin: String? = null, to: Any? = null)

Applies the given plugin or script.

Link copied to clipboard
inline fun <T : Plugin<*>> PluginAware.applyTo(vararg targets: Any)

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

Link copied to clipboard
abstract fun buildCache(action: Action<in BuildCacheConfiguration>)
Configures build cache.
Link copied to clipboard
abstract fun caches(cachesConfiguration: Action<in CacheConfigurations>)
Configures the settings for caches stored in the user home directory.
Link copied to clipboard
inline fun <T : Any> ExtensionAware.configure(noinline configuration: T.() -> Unit)

Executes the given configuration block against the extension of the specified type.

Link copied to clipboard
abstract fun defaults(action: Action<in SharedModelDefaults>)
Configures the model defaults for this build.
Link copied to clipboard
abstract fun dependencyResolutionManagement(dependencyResolutionConfiguration: Action<in DependencyResolutionManagement>)
Configures the cross-project dependency resolution aspects
Link copied to clipboard
abstract fun enableFeaturePreview(name: String)
Enables a feature preview by name.
Link copied to clipboard
@Nullable
abstract fun findProject(projectDir: File): ProjectDescriptor
Returns the project with the given project directory.
@Nullable
abstract fun findProject(path: String): ProjectDescriptor
Returns the project with the given path.
Link copied to clipboard
Returns the build cache configuration.
Link copied to clipboard
Returns the build script handler for settings.
Link copied to clipboard
Returns the configuration for caches stored in the user home directory.
Link copied to clipboard
Returns the model defaults object for this build.
Link copied to clipboard
Returns the dependency resolution management handler.
Link copied to clipboard
Link copied to clipboard
abstract fun getGradle(): Gradle
Returns the Gradle instance for the current build.
Link copied to clipboard
Provides access to important locations for a Gradle build.
Link copied to clipboard
Returns the plugin management configuration.
Link copied to clipboard
Link copied to clipboard
abstract fun getPlugins(): PluginContainer
Link copied to clipboard
Provides access to methods to create various kinds of Provider instances.
Link copied to clipboard
abstract fun getRootDir(): File
Returns the root directory of the build.
Link copied to clipboard
Returns the root project of the build.
Link copied to clipboard
abstract fun getSettings(): Settings
Returns this settings object.
Link copied to clipboard
abstract fun getSettingsDir(): File
Returns the settings directory of the build.
Link copied to clipboard
Returns the source control configuration.
Link copied to clipboard
Returns the set of parameters used to invoke this instance of Gradle.
Link copied to clipboard
Returns the toolchain management configuration.
Link copied to clipboard
abstract fun include(projectPaths: Iterable<String>)
open fun include(projectPaths: Array<String>)
Adds the given projects to the build.
Link copied to clipboard
abstract fun includeBuild(rootProject: Any)
Includes a build at the specified path to the composite build.
abstract fun includeBuild(rootProject: Any, configuration: Action<ConfigurableIncludedBuild>)
Includes a build at the specified path to the composite build, with the supplied configuration.
Link copied to clipboard
abstract fun includeFlat(projectNames: Iterable<String>)
open fun includeFlat(projectNames: Array<String>)
Adds the given projects to the build.
Link copied to clipboard
abstract fun pluginManagement(pluginManagementSpec: Action<in PluginManagementSpec>)
Configures plugin management.
Link copied to clipboard
abstract fun project(projectDir: File): ProjectDescriptor
Returns the project with the given project directory.
abstract fun project(path: String): ProjectDescriptor
Returns the project with the given path.
Link copied to clipboard
operator fun Settings.provideDelegate(any: Any?, property: KProperty<*>): PropertyDelegate

Locates a property on Settings.

Link copied to clipboard
abstract fun sourceControl(configuration: Action<in SourceControl>)
Configures source control.
Link copied to clipboard
inline fun <T : Any> ExtensionAware.the(): T

Returns the extension of the specified type.

fun <T : Any> ExtensionAware.the(extensionType: KClass<T>): T

Returns the extension of the specified extensionType.

Link copied to clipboard
abstract fun toolchainManagement(toolchainManagementConfiguration: Action<in ToolchainManagement>)
Configures toolchain management.