Interface ConfigurationContainer

All Superinterfaces:
Collection<Configuration>, Configurable<NamedDomainObjectContainer<Configuration>>, DomainObjectCollection<Configuration>, DomainObjectSet<Configuration>, Iterable<Configuration>, NamedDomainObjectCollection<Configuration>, NamedDomainObjectContainer<Configuration>, NamedDomainObjectSet<Configuration>, Set<Configuration>

@ServiceScope(org.gradle.internal.service.scopes.Scope.Project.class) 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
 }
 

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: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.