ExtensionAware
, PluginAware
public interface Settings extends PluginAware, ExtensionAware
Declares the configuration required to instantiate and configure the hierarchy of Project
instances which are to participate in a build.
There is a one-to-one correspondence between a Settings
instance and a "settings.gradle"
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.
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:
.gradle
directory.Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
DEFAULT_SETTINGS_FILE |
The default name for the settings file.
|
Modifier and Type | Method | Description |
---|---|---|
void |
buildCache(Action<? super BuildCacheConfiguration> action) |
Configures build cache.
|
void |
caches(Action<? super CacheConfigurations> cachesConfiguration) |
Configures the settings for caches stored in the user home directory.
|
void |
dependencyResolutionManagement(Action<? super DependencyResolutionManagement> dependencyResolutionConfiguration) |
Configures the cross-project dependency resolution aspects
|
void |
enableFeaturePreview(java.lang.String name) |
Enables a feature preview by name.
|
ProjectDescriptor |
findProject(java.io.File projectDir) |
Returns the project with the given project directory.
|
ProjectDescriptor |
findProject(java.lang.String path) |
Returns the project with the given path.
|
BuildCacheConfiguration |
getBuildCache() |
Returns the build cache configuration.
|
ScriptHandler |
getBuildscript() |
Returns the build script handler for settings.
|
CacheConfigurations |
getCaches() |
Returns the configuration for caches stored in the user home directory.
|
DependencyResolutionManagement |
getDependencyResolutionManagement() |
Returns the dependency resolution management handler.
|
Gradle |
getGradle() |
Returns the
Gradle instance for the current build. |
PluginManagementSpec |
getPluginManagement() |
Returns the plugin management configuration.
|
ProviderFactory |
getProviders() |
Provides access to methods to create various kinds of
Provider instances. |
java.io.File |
getRootDir() |
Returns the root directory of the build.
|
ProjectDescriptor |
getRootProject() |
Returns the root project of the build.
|
Settings |
getSettings() |
Returns this settings object.
|
java.io.File |
getSettingsDir() |
Returns the settings directory of the build.
|
SourceControl |
getSourceControl() |
Returns the source control configuration.
|
StartParameter |
getStartParameter() |
Returns the set of parameters used to invoke this instance of Gradle.
|
ToolchainManagement |
getToolchainManagement() |
Returns the toolchain management configuration.
|
void |
include(java.lang.Iterable<java.lang.String> projectPaths) |
Adds the given projects to the build.
|
default void |
include(java.lang.String... projectPaths) |
Adds the given projects to the build.
|
void |
includeBuild(java.lang.Object rootProject) |
Includes a build at the specified path to the composite build.
|
void |
includeBuild(java.lang.Object rootProject,
Action<ConfigurableIncludedBuild> configuration) |
Includes a build at the specified path to the composite build, with the supplied configuration.
|
void |
includeFlat(java.lang.Iterable<java.lang.String> projectNames) |
Adds the given projects to the build.
|
default void |
includeFlat(java.lang.String... projectNames) |
Adds the given projects to the build.
|
void |
pluginManagement(Action<? super PluginManagementSpec> pluginManagementSpec) |
Configures plugin management.
|
ProjectDescriptor |
project(java.io.File projectDir) |
Returns the project with the given project directory.
|
ProjectDescriptor |
project(java.lang.String path) |
Returns the project with the given path.
|
void |
sourceControl(Action<? super SourceControl> configuration) |
Configures source control.
|
void |
toolchainManagement(Action<? super ToolchainManagement> toolchainManagementConfiguration) |
Configures toolchain management.
|
getExtensions
apply, apply, apply, getPluginManager, getPlugins
static final java.lang.String DEFAULT_SETTINGS_FILE
The default name for the settings file.
default void include(java.lang.String... projectPaths)
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 }
projectPaths
- the projects to add.void include(java.lang.Iterable<java.lang.String> projectPaths)
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 }
projectPaths
- the projects to add.default void includeFlat(java.lang.String... projectNames)
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
.
projectNames
- the projects to add.void includeFlat(java.lang.Iterable<java.lang.String> projectNames)
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
.
projectNames
- the projects to add.Settings getSettings()
Returns this settings object.
ScriptHandler getBuildscript()
java.io.File getSettingsDir()
Returns the settings directory of the build. The settings directory is the directory containing the settings file.
java.io.File getRootDir()
Returns the root directory of the build. The root directory is the project directory of the root project.
ProjectDescriptor getRootProject()
Returns the root project of the build.
ProjectDescriptor project(java.lang.String path) throws UnknownProjectException
Returns the project with the given path.
path
- The path.UnknownProjectException
- If no project with the given path exists.@Nullable ProjectDescriptor findProject(java.lang.String path)
Returns the project with the given path.
path
- The pathProjectDescriptor project(java.io.File projectDir) throws UnknownProjectException
Returns the project with the given project directory.
projectDir
- The project directory.UnknownProjectException
- If no project with the given path exists.@Nullable ProjectDescriptor findProject(java.io.File projectDir)
Returns the project with the given project directory.
projectDir
- The project directory.StartParameter getStartParameter()
Returns the set of parameters used to invoke this instance of Gradle.
ProviderFactory getProviders()
Provider
instances.Gradle getGradle()
Gradle
instance for the current build.void includeBuild(java.lang.Object rootProject)
rootProject
- The path to the root project directory for the build.void includeBuild(java.lang.Object rootProject, Action<ConfigurableIncludedBuild> configuration)
rootProject
- The path to the root project directory for the build.configuration
- An action to configure the included build.BuildCacheConfiguration getBuildCache()
void buildCache(Action<? super BuildCacheConfiguration> action)
void pluginManagement(Action<? super PluginManagementSpec> pluginManagementSpec)
PluginManagementSpec getPluginManagement()
void sourceControl(Action<? super SourceControl> configuration)
SourceControl getSourceControl()
void enableFeaturePreview(java.lang.String name)
name
- the name of the feature to enablevoid dependencyResolutionManagement(Action<? super DependencyResolutionManagement> dependencyResolutionConfiguration)
dependencyResolutionConfiguration
- the configurationDependencyResolutionManagement getDependencyResolutionManagement()
@Incubating void toolchainManagement(Action<? super ToolchainManagement> toolchainManagementConfiguration)
@Incubating ToolchainManagement getToolchainManagement()
@Incubating CacheConfigurations getCaches()
@Incubating void caches(Action<? super CacheConfigurations> cachesConfiguration)
cachesConfiguration
- the configuration