java.util.Collection<Configuration>
, Configurable<NamedDomainObjectContainer<Configuration>>
, DomainObjectCollection<Configuration>
, DomainObjectSet<Configuration>
, java.lang.Iterable<Configuration>
, NamedDomainObjectCollection<Configuration>
, NamedDomainObjectContainer<Configuration>
, NamedDomainObjectSet<Configuration>
, java.util.Set<Configuration>
public interface ConfigurationContainer extends NamedDomainObjectContainer<Configuration>
A ConfigurationContainer
is responsible for declaring and managing configurations. See also Configuration
.
You can obtain a ConfigurationContainer
instance by calling Project.getConfigurations()
,
or using the configurations
property in your build script.
The configurations in a container are accessible as read-only properties of the container, using the name of the configuration as the property name. For example:
configurations.create('myConfiguration') configurations.myConfiguration.transitive = false
A dynamic method is added for each configuration which takes a configuration closure. This is equivalent to
calling getByName(String, groovy.lang.Closure)
. For example:
configurations.create('myConfiguration') configurations.myConfiguration { transitive = false }
plugins { id 'java' //so that I can use 'implementation', 'compileClasspath' configuration } dependencies { implementation 'org.slf4j:slf4j-api:1.7.26' } //copying all dependencies attached to 'compileClasspath' into a specific folder task copyAllDependencies(type: Copy) { //referring to the 'compileClasspath' configuration from configurations.compileClasspath into 'allLibs' }An example showing how to declare and configure configurations
plugins { id 'java' // so that I can use 'implementation', 'testImplementation' configurations } configurations { //adding a configuration: myConfiguration //adding a configuration that extends existing configuration: //(testImplementation was added by the java plugin) myIntegrationTestsCompile.extendsFrom(testImplementation) //configuring existing configurations not to put transitive dependencies on the compile classpath //this way you can avoid issues with implicit dependencies to transitive libraries compileClasspath.transitive = false testCompileClasspath.transitive = false }Examples on configuring the resolution strategy - see docs for
ResolutionStrategy
Please see the Managing Dependency Configurations User Manual chapter for more information.Modifier and Type | Method | Description |
---|---|---|
NamedDomainObjectProvider<ConsumableConfiguration> |
consumable(java.lang.String name) |
Registers a new
ConsumableConfiguration with an immutable role. |
NamedDomainObjectProvider<ConsumableConfiguration> |
consumable(java.lang.String name,
Action<? super ConsumableConfiguration> action) |
Registers a
ConsumableConfiguration via consumable(String) and then
configures it with the provided action. |
NamedDomainObjectProvider<DependencyScopeConfiguration> |
dependencyScope(java.lang.String name) |
Registers a new
DependencyScopeConfiguration with an immutable role. |
NamedDomainObjectProvider<DependencyScopeConfiguration> |
dependencyScope(java.lang.String name,
Action<? super DependencyScopeConfiguration> action) |
Registers a
DependencyScopeConfiguration via dependencyScope(String) and then
configures it with the provided action. |
Configuration |
detachedConfiguration(Dependency... dependencies) |
Creates a configuration, but does not add it to this container.
|
Configuration |
getAt(java.lang.String name) |
Locates an object by name, failing if there is no such object.
|
Configuration |
getByName(java.lang.String name) |
Locates an object by name, failing if there is no such object.
|
Configuration |
getByName(java.lang.String name,
Closure configureClosure) |
Locates an object by name, failing if there is no such object.
|
Configuration |
getByName(java.lang.String name,
Action<? super Configuration> configureAction) |
Locates an object by name, failing if there is no such object.
|
NamedDomainObjectProvider<ResolvableConfiguration> |
resolvable(java.lang.String name) |
Registers a
ResolvableConfiguration with an immutable role. |
NamedDomainObjectProvider<ResolvableConfiguration> |
resolvable(java.lang.String name,
Action<? super ResolvableConfiguration> action) |
Registers a
ResolvableConfiguration via resolvable(String) and then
configures it with the provided action. |
addAllLater, addLater, all, all, configureEach, whenObjectAdded, whenObjectAdded, whenObjectRemoved, whenObjectRemoved, withType, withType
add, addAll, addRule, addRule, addRule, findByName, getAsMap, getCollectionSchema, getNamer, getNames, getRules, named, named, named, named
configure, create, create, create, maybeCreate, register, register
Configuration getByName(java.lang.String name) throws UnknownConfigurationException
getByName
in interface NamedDomainObjectCollection<Configuration>
name
- The object nameUnknownConfigurationException
Configuration getAt(java.lang.String name) throws UnknownConfigurationException
NamedDomainObjectCollection.getByName(String)
. You can call this method in your build script by using the groovy []
operator.getAt
in interface NamedDomainObjectCollection<Configuration>
name
- The object nameUnknownConfigurationException
Configuration getByName(java.lang.String name, @DelegatesTo(Configuration.class) Closure configureClosure) throws UnknownConfigurationException
getByName
in interface NamedDomainObjectCollection<Configuration>
name
- The object nameconfigureClosure
- The closure to use to configure the object.UnknownConfigurationException
Configuration getByName(java.lang.String name, Action<? super Configuration> configureAction) throws UnknownConfigurationException
getByName
in interface NamedDomainObjectCollection<Configuration>
name
- The object nameconfigureAction
- The action to use to configure the object.UnknownConfigurationException
Configuration detachedConfiguration(Dependency... dependencies)
dependencies
- The dependencies of the configuration.@Incubating NamedDomainObjectProvider<ResolvableConfiguration> resolvable(java.lang.String name)
ResolvableConfiguration
with an immutable role. Resolvable configurations
are meant to resolve dependency graphs and their artifacts.name
- The name of the configuration to register.InvalidUserDataException
- If a configuration with the given name
already exists in this container.@Incubating NamedDomainObjectProvider<ResolvableConfiguration> resolvable(java.lang.String name, Action<? super ResolvableConfiguration> action)
ResolvableConfiguration
via resolvable(String)
and then
configures it with the provided action.name
- The name of the configuration to register.action
- The action to apply to the configuration.InvalidUserDataException
- If a configuration with the given name
already exists in this container.@Incubating NamedDomainObjectProvider<ConsumableConfiguration> consumable(java.lang.String name)
ConsumableConfiguration
with an immutable role. Consumable configurations
are meant to act as a variant in the context of Dependency Management and Publishing.name
- The name of the configuration to register.InvalidUserDataException
- If a configuration with the given name
already exists in this container.@Incubating NamedDomainObjectProvider<ConsumableConfiguration> consumable(java.lang.String name, Action<? super ConsumableConfiguration> action)
ConsumableConfiguration
via consumable(String)
and then
configures it with the provided action.name
- The name of the configuration to register.action
- The action to apply to the configuration.InvalidUserDataException
- If a configuration with the given name
already exists in this container.@Incubating NamedDomainObjectProvider<DependencyScopeConfiguration> dependencyScope(java.lang.String name)
DependencyScopeConfiguration
with an immutable role. Dependency scope configurations
collect dependencies, dependency constraints, and exclude rules to be used by both resolvable
and consumable configurations.name
- The name of the configuration to register.InvalidUserDataException
- If a configuration with the given name
already exists in this container.@Incubating NamedDomainObjectProvider<DependencyScopeConfiguration> dependencyScope(java.lang.String name, Action<? super DependencyScopeConfiguration> action)
DependencyScopeConfiguration
via dependencyScope(String)
and then
configures it with the provided action.name
- The name of the configuration to register.action
- The action to apply to the configuration.InvalidUserDataException
- If a configuration with the given name
already exists in this container.