# ConfigurationContainer

@ServiceScope(value = Project::class)
interface ConfigurationContainer : NamedDomainObjectContainer<T> (source)

A `ConfigurationContainer` is responsible for declaring and managing configurations. See also Configuration.

You can obtain a `ConfigurationContainer` instance by calling 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

Content copied to clipboard

A dynamic method is added for each configuration which takes a configuration closure. This is equivalent to calling getByName. For example:

    configurations.create('myConfiguration')
    configurations.myConfiguration {
        transitive = false
    }

Content copied to clipboard

## Examples

An example showing how to refer to a given configuration by name in order to get hold of all dependencies (e.g. jars, but only)

      plugins {
          id 'java' //so that I can use 'implementation', 'compileClasspath' configuration
      }

      dependencies {
          implementation 'org.slf4j:slf4j-api:2.0.17'
      }

      //copying all dependencies attached to 'compileClasspath' into a specific folder
      task copyAllDependencies(type: Copy) {
        //referring to the 'compileClasspath' configuration
        from configurations.compileClasspath
        into 'allLibs'
      }

Content copied to clipboard
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
    }

Content copied to clipboard
Examples on configuring the resolution strategy - see docs for ResolutionStrategy Please see the Managing Dependency Configurations User Manual chapter for more information.

## Properties

creating
Link copied to clipboard
val <T : Any> NamedDomainObjectContainer<T>.creating: NamedDomainObjectContainerCreatingDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type.

## Functions

add
Link copied to clipboard
abstract fun add(e: T): Boolean
addAll
Link copied to clipboard
abstract fun addAll(c: Collection<out T>): Boolean
addAllLater
Link copied to clipboard
abstract fun addAllLater(provider: Provider<out Iterable<T>>)
addLater
Link copied to clipboard
abstract fun addLater(provider: Provider<out T>)
addRule
Link copied to clipboard
abstract fun addRule(rule: Rule): Rule
all
Link copied to clipboard
abstract fun all(action: Action<in T>)
areChangesAllowed
Link copied to clipboard
open fun areChangesAllowed(): Boolean
clear
Link copied to clipboard
abstract fun clear()
configure
Link copied to clipboard
abstract fun configure(configureClosure: Closure): NamedDomainObjectContainer<T>
abstract fun configure(cl: Closure): T
configureEach
Link copied to clipboard
abstract fun configureEach(action: Action<in T>)
consumable
Link copied to clipboard
@Incubating
abstract fun consumable(name: String): NamedDomainObjectProvider<ConsumableConfiguration>
Registers a new ConsumableConfiguration with an immutable role.
@Incubating
abstract fun consumable(name: String, action: Action<in ConsumableConfiguration>): NamedDomainObjectProvider<ConsumableConfiguration>
Registers a ConsumableConfiguration via consumable and then configures it with the provided action.
contains
Link copied to clipboard
abstract fun contains(p: Any): Boolean
containsAll
Link copied to clipboard
abstract fun containsAll(p: Collection<out Any>): Boolean
copyOf
Link copied to clipboard
open fun <E> copyOf(p: Collection<out E>): Set<E>
create
Link copied to clipboard
abstract fun create(name: String): T
creating
Link copied to clipboard
fun <T : Any> NamedDomainObjectContainer<T>.creating(configuration: T.() -> Unit): NamedDomainObjectContainerCreatingDelegateProvider<T>

Provides a property delegate that creates elements of the default collection type with the given configuration.

dependencyScope
Link copied to clipboard
@Incubating
abstract fun dependencyScope(name: String): NamedDomainObjectProvider<DependencyScopeConfiguration>
Registers a new DependencyScopeConfiguration with an immutable role.
@Incubating
abstract fun dependencyScope(name: String, action: Action<in DependencyScopeConfiguration>): NamedDomainObjectProvider<DependencyScopeConfiguration>
Registers a DependencyScopeConfiguration via dependencyScope and then configures it with the provided action.
detachedConfiguration
Link copied to clipboard
abstract fun detachedConfiguration(dependencies: Array<Dependency>): Configuration
Creates a configuration, but does not add it to this container.
disallowChanges
Link copied to clipboard
open fun disallowChanges()
equals
Link copied to clipboard
abstract fun equals(p: Any): Boolean
findAll
Link copied to clipboard
abstract fun findAll(spec: Closure): Collection<T>
abstract fun findAll(spec: Closure): Set<T>
findByName
Link copied to clipboard
abstract fun findByName(name: String): @Nullable T
forEach
Link copied to clipboard
open fun forEach(p: Consumer<in T>)
get
Link copied to clipboard
operator fun <T : Any> NamedDomainObjectCollection<T>.get(name: String): T

Locates an object by name, failing if there is no such object.

getAsMap
Link copied to clipboard
abstract fun getAsMap(): SortedMap<String, T>
getAt
Link copied to clipboard
abstract fun getAt(name: String): Configuration
getByName
Link copied to clipboard
abstract fun getByName(name: String): Configuration
abstract fun getByName(name: String, @DelegatesTo(value = Configuration::class) configureClosure: Closure): Configuration
abstract fun getByName(name: String, configureAction: Action<in Configuration>): Configuration
getByName
Link copied to clipboard
inline fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String): <Error class: unknown class>

Locates an object by name and casts it to the expected type T.

inline fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, configure: T.() -> Unit): <Error class: unknown class>

Locates an object by name and casts it to the expected type T then configures it.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>): T

Locates an object by name and casts it to the expected type.

fun <T : Any> NamedDomainObjectCollection<out Any>.getByName(name: String, type: KClass<T>, configure: T.() -> Unit): T

Locates an object by name and casts it to the expected type then configures it.

getCollectionSchema
Link copied to clipboard
abstract fun getCollectionSchema(): NamedDomainObjectCollectionSchema
getNamer
Link copied to clipboard
abstract fun getNamer(): Namer<T>
getNames
Link copied to clipboard
abstract fun getNames(): SortedSet<String>
getRules
Link copied to clipboard
abstract fun getRules(): List<Rule>
getting
Link copied to clipboard
fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>): PolymorphicDomainObjectContainerGettingDelegateProvider<T, U>

Provides a property delegate that gets elements of the given type.

fun <T : Any, U : T> NamedDomainObjectContainer<T>.getting(type: KClass<U>, configuration: U.() -> Unit): PolymorphicDomainObjectContainerGettingDelegateProvider<T, U>

Provides a property delegate that gets elements of the given type and applies the given configuration.

hashCode
Link copied to clipboard
abstract fun hashCode(): Int
invoke
Link copied to clipboard
inline operator fun ConfigurationContainer.invoke(configuration: Action<ConfigurationContainerScope>): ConfigurationContainer

Allows the container to be configured via an augmented DSL.

isEmpty
Link copied to clipboard
abstract fun isEmpty(): Boolean
iterator
Link copied to clipboard
abstract fun iterator(): Iterator<T>
abstract fun iterator(): Iterator<E>
matching
Link copied to clipboard
abstract fun matching(spec: Spec<in T>): DomainObjectCollection<T>
abstract fun matching(spec: Spec<in T>): DomainObjectSet<T>
abstract fun matching(spec: Spec<in T>): NamedDomainObjectCollection<T>
abstract fun matching(spec: Spec<in T>): NamedDomainObjectSet<T>
maybeCreate
Link copied to clipboard
abstract fun maybeCreate(name: String): T
named
Link copied to clipboard
abstract fun named(name: String): NamedDomainObjectProvider<T>
open fun named(nameFilter: Spec<String>): NamedDomainObjectCollection<T>
abstract fun <S : T?> named(name: String, type: Class<S>): NamedDomainObjectProvider<S>
abstract fun named(nameFilter: Spec<String>): NamedDomainObjectSet<T>
named
Link copied to clipboard
inline fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String): NamedDomainObjectProvider<T>
fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, type: KClass<T>): NamedDomainObjectProvider<T>

Locates an object by name and type, without triggering its creation or configuration, failing if there is no such object.

inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.named(name: String, type: KClass<S>): NamedDomainObjectProvider<S>
inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.named(name: String, type: KClass<S>, configurationAction: Action<in S>): NamedDomainObjectProvider<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectCollection.named.

inline fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, noinline configuration: T.() -> Unit): NamedDomainObjectProvider<T>
fun <T : Any> NamedDomainObjectCollection<out Any>.named(name: String, type: KClass<T>, configuration: T.() -> Unit): NamedDomainObjectProvider<T>

Configures an object by name and type, without triggering its creation or configuration, failing if there is no such object.

of
Link copied to clipboard
open fun <E> of(): Set<E>
parallelStream
Link copied to clipboard
open fun parallelStream(): Stream<E>
provideDelegate
Link copied to clipboard
operator fun <T : Any> NamedDomainObjectCollection<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): NamedDomainObjectProvider<T>

Allows a NamedDomainObjectCollection to be used as a property delegate.

register
Link copied to clipboard
abstract fun register(name: String, configurationAction: Action<in T>): NamedDomainObjectProvider<T>
remove
Link copied to clipboard
abstract fun remove(p: Any): Boolean
removeAll
Link copied to clipboard
abstract fun removeAll(p: Collection<out Any>): Boolean
removeIf
Link copied to clipboard
open fun removeIf(p: Predicate<in E>): Boolean
resolvable
Link copied to clipboard
@Incubating
abstract fun resolvable(name: String): NamedDomainObjectProvider<ResolvableConfiguration>
Registers a ResolvableConfiguration with an immutable role.
@Incubating
abstract fun resolvable(name: String, action: Action<in ResolvableConfiguration>): NamedDomainObjectProvider<ResolvableConfiguration>
Registers a ResolvableConfiguration via resolvable and then configures it with the provided action.
retainAll
Link copied to clipboard
abstract fun retainAll(p: Collection<out Any>): Boolean
size
Link copied to clipboard
abstract fun size(): Int
spliterator
Link copied to clipboard
open fun spliterator(): Spliterator<T>
open fun spliterator(): Spliterator<E>
stream
Link copied to clipboard
open fun stream(): Stream<E>
toArray
Link copied to clipboard
abstract fun toArray(): Array<Any>
abstract fun <T> toArray(p: Array<T>): Array<T>
whenObjectAdded
Link copied to clipboard
abstract fun whenObjectAdded(action: Closure)
abstract fun whenObjectAdded(action: Action<in T>): Action<in T>
whenObjectRemoved
Link copied to clipboard
abstract fun whenObjectRemoved(action: Closure)
abstract fun whenObjectRemoved(action: Action<in T>): Action<in T>
withType
Link copied to clipboard
abstract fun <S : T?> withType(type: Class<S>): DomainObjectCollection<S>
abstract fun <S : T?> withType(type: Class<S>): DomainObjectSet<S>
abstract fun <S : T?> withType(type: Class<S>): NamedDomainObjectCollection<S>
abstract fun <S : T?> withType(type: Class<S>): NamedDomainObjectSet<S>
withType
Link copied to clipboard
inline fun <S : Any> DomainObjectCollection<in S>.withType(): <Error class: unknown class>
inline fun <S : Any> NamedDomainObjectCollection<in S>.withType(): NamedDomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. The returned collection is live, so that when matching objects are later added to this collection, they are also visible in the filtered collection.

inline fun <S : Any> DomainObjectCollection<in S>.withType(noinline configuration: S.() -> Unit): DomainObjectCollection<S>

Returns a collection containing the objects in this collection of the given type. Equivalent to calling `withType(type).all(configureAction)`.

inline fun <S : T, T : Any> DomainObjectCollection<T>.withType(type: KClass<S>): DomainObjectCollection<S>
inline fun <S : T, T : Any> DomainObjectCollection<T>.withType(type: KClass<S>, configureAction: Action<in S>): DomainObjectCollection<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.DomainObjectCollection.withType.

inline fun <S : T, T : Any> DomainObjectSet<T>.withType(type: KClass<S>): DomainObjectSet<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.DomainObjectSet.withType.

inline fun <S : T, T : Any> NamedDomainObjectCollection<T>.withType(type: KClass<S>): NamedDomainObjectCollection<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectCollection.withType.

inline fun <S : T, T : Any> NamedDomainObjectSet<T>.withType(type: KClass<S>): NamedDomainObjectSet<S>

Kotlin extension function taking kotlin.reflect.KClass for org.gradle.api.NamedDomainObjectSet.withType.