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.
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 PropertiesIn 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:
.gradle
directory.
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 As an example, the path Some common examples of using the project path are:
|
|
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 |
|
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. |
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 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:
|
|
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 Use one of the 'apply' methods on this interface or on the Use |
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. |