# ConfigurationContainer

API Documentation: | `ConfigurationContainer`

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 `ConfigurationContainer.getByName(java.lang.String, groovy.lang.Closure)`. For example:

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

### 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)

    apply plugin: 'java' //so that I can use 'compile' configuration

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

An example showing how to declare and configure configurations

    apply plugin: 'java' //so that I can use 'compile', 'testCompile' configurations

    configurations {
      //adding a configuration:
      myConfiguration

      //adding a configuration that extends existing configuration:
      //(testCompile was added by the java plugin)
      myIntegrationTestsCompile.extendsFrom(testCompile)

      //configuring existing configurations not to put transitive dependencies on the compile classpath
      //this way you can avoid issues with implicit dependencies to transitive libraries
      compile.transitive = false
      testCompile.transitive = false
    }

Examples on configuring the resolution strategy - see docs for `ResolutionStrategy`

### Properties

No properties

### Methods

Method | Description
`create(name)` | Creates a new item with the given name, adding it to this container.
`create(name, configureClosure)` | Creates a new item with the given name, adding it to this container, then configuring it with the given closure.
`create(name, configureAction)` | Creates a new item with the given name, adding it to this container, then configuring it with the given action.
`detachedConfiguration(dependencies)` | Creates a configuration, but does not add it to this container.
`getAt(name)` | Locates an object by name, failing if there is no such task. This method is identical to `NamedDomainObjectCollection.getByName(java.lang.String)`. You can call this method in your build script by using the groovy `[]` operator.
`getByName(name)` | Locates an object by name, failing if there is no such object.
`getByName(name, configureClosure)` | Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.
`getByName(name, configureAction)` | Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.
`maybeCreate(name)` | Looks for an item with the given name, creating and adding it to this container if it does not exist.

### Script blocks

No script blocks

### Method details

#### `T` `create`(`String` name)

Creates a new item with the given name, adding it to this container.

#### `T` `create`(`String` name, `Closure` configureClosure)

Creates a new item with the given name, adding it to this container, then configuring it with the given closure.

#### `T` `create`(`String` name, ``Action`<? super `T`>` configureAction)

Creates a new item with the given name, adding it to this container, then configuring it with the given action.

#### `Configuration` `detachedConfiguration`(``Dependency`...` dependencies)

Creates a configuration, but does not add it to this container.

#### `Configuration` `getAt`(`String` name)

Locates an object by name, failing if there is no such task. This method is identical to `NamedDomainObjectCollection.getByName(java.lang.String)`. You can call this method in your build script by using the groovy `[]` operator.

#### `Configuration` `getByName`(`String` name)

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

#### `Configuration` `getByName`(`String` name, `Closure` configureClosure)

Locates an object by name, failing if there is no such object. The given configure closure is executed against the object before it is returned from this method. The object is passed to the closure as its delegate.

#### `Configuration` `getByName`(`String` name, ``Action`<? super `Configuration`>` configureAction)

Locates an object by name, failing if there is no such object. The given configure action is executed against the object before it is returned from this method.

#### `T` `maybeCreate`(`String` name)

Looks for an item with the given name, creating and adding it to this container if it does not exist.