Settings

Declares the configuration required to instantiate and configure the hierarchy of org.gradle.api.Project 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.

Functions

Link copied to clipboard
abstract fun apply(@DelegatesTo(value = ObjectConfigurationAction::class) closure: Closure)
abstract fun apply(action: Action<in ObjectConfigurationAction>)
Applies zero or more plugins or scripts.
abstract fun apply(options: Map<String, out Any>)
Applies a plugin or script, using the given options provided as a map.
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
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): @Nullable ProjectDescriptor
Returns the project with the given project directory.
@Nullable
abstract fun findProject(path: String): @Nullable 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
The container of extensions.
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
The plugin manager for this plugin aware object.
Link copied to clipboard
abstract fun getPlugins(): PluginContainer
The container of plugins that have been applied to this object.
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
abstract fun sourceControl(configuration: Action<in SourceControl>)
Configures source control.
Link copied to clipboard
abstract fun toolchainManagement(toolchainManagementConfiguration: Action<in ToolchainManagement>)
Configures toolchain management.