Package org.gradle.api.artifacts

## Interface Configuration

- All Superinterfaces:
    `AntBuilderAware`, `Buildable`, `FileCollection`, `HasAttributes`, `HasConfigurableAttributes<Configuration>`, `Iterable<File>`

      public interface Configuration
      extends FileCollection, HasConfigurableAttributes<Configuration>

  A `Configuration` represents a group of artifacts and their dependencies. Find more information about declaring dependencies to a configuration or about managing configurations in docs for `ConfigurationContainer`

  Configuration is an instance of a `FileCollection` that contains all dependencies (see also `getAllDependencies()`) but not artifacts. If you want to refer to the artifacts declared in this configuration please use `getArtifacts()` or `getAllArtifacts()`. Read more about declaring artifacts in the configuration in docs for `ArtifactHandler` Please see the Declaring Dependencies User Manual chapter for more information.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface | Description
    --- | --- | ---
    `static class` | `Configuration.Namer` | A `Namer` namer for configurations that returns `getName()`.
    `static class` | `Configuration.State` | The states a configuration can be into.

    - ### Nested classes/interfaces inherited from interface org.gradle.api.file.FileCollection

      `FileCollection.AntType`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Deprecated Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Configuration` | `copy()` | Creates a copy of this configuration that only contains the dependencies directly in this configuration (without contributions from superconfigurations).
    `Configuration` | `copy​(Closure dependencySpec)` | Takes a closure which gets coerced into a `Spec`.
    `Configuration` | `copy​(Spec<? super Dependency> dependencySpec)` | Creates a copy of this configuration ignoring superconfigurations (see `copy()` but filtering the dependencies using the specified dependency spec.
    `Configuration` | `copyRecursive()` | Creates a copy of this configuration that contains the dependencies directly in this configuration and those derived from superconfigurations.
    `Configuration` | `copyRecursive​(Closure dependencySpec)` | Takes a closure which gets coerced into a `Spec`.
    `Configuration` | `copyRecursive​(Spec<? super Dependency> dependencySpec)` | Creates a copy of this configuration with dependencies from superconfigurations (see `copyRecursive()`) but filtering the dependencies using the dependencySpec.
    `Configuration` | `defaultDependencies​(Action<? super DependencySet> action)` | Execute the given action if the configuration has no defined dependencies when it first participates in dependency resolution.
    `Configuration` | `disableConsistentResolution()` | Disables consistent resolution for this configuration
    `Configuration` | `exclude​(Map<String,​String> excludeProperties)` | Adds an exclude rule to exclude transitive dependencies for all dependencies of this configuration.
    `Configuration` | `extendsFrom​(Configuration... superConfigs)` | Adds the given configurations to the set of configuration which this configuration extends from.
    `FileCollection` | `fileCollection​(Closure dependencySpecClosure)` | Takes a closure which gets coerced into a `Spec`.
    `FileCollection` | `fileCollection​(Dependency... dependencies)` | Resolves this configuration lazily.
    `FileCollection` | `fileCollection​(Spec<? super Dependency> dependencySpec)` | Resolves this configuration lazily.
    `Set<File>` | `files​(Closure dependencySpecClosure)` | Takes a closure which gets coerced into a `Spec`.
    `Set<File>` | `files​(Dependency... dependencies)` | Resolves this configuration.
    `Set<File>` | `files​(Spec<? super Dependency> dependencySpec)` | Resolves this configuration.
    `Set<Configuration>` | `getAll()` | Returns all the configurations belonging to the same configuration container as this configuration (including this configuration).
    `PublishArtifactSet` | `getAllArtifacts()` | Returns the artifacts of this configuration including the artifacts of extended configurations.
    `DependencySet` | `getAllDependencies()` | Gets the complete set of declared dependencies including those contributed by superconfigurations.
    `DependencyConstraintSet` | `getAllDependencyConstraints()` | Gets the complete set of dependency constraints including those contributed by superconfigurations.
    `PublishArtifactSet` | `getArtifacts()` | Returns the artifacts of this configuration excluding the artifacts of extended configurations.
    `TaskDependency` | `getBuildDependencies()` | Returns a `TaskDependency` object containing all required dependencies to build the local dependencies (e.g. project dependencies) belonging to this configuration or to one of its super configurations.
    `DependencySet` | `getDependencies()` | Gets the set of declared dependencies directly contained in this configuration (ignoring superconfigurations).
    `DependencyConstraintSet` | `getDependencyConstraints()` | Gets the set of dependency constraints directly contained in this configuration (ignoring superconfigurations).
    `String` | `getDescription()` | Returns the description for this configuration.
    `Set<ExcludeRule>` | `getExcludeRules()` | Returns the exclude rules applied for resolving any dependency of this configuration.
    `Set<Configuration>` | `getExtendsFrom()` | Returns the names of the configurations which this configuration extends from.
    `Set<Configuration>` | `getHierarchy()` | Gets a ordered set including this configuration and all superconfigurations recursively.
    `ResolvableDependencies` | `getIncoming()` | Returns the incoming dependencies of this configuration.
    `String` | `getName()` | Returns the name of this configuration.
    `ConfigurationPublications` | `getOutgoing()` | Returns the outgoing artifacts of this configuration.
    `ResolutionStrategy` | `getResolutionStrategy()` | Returns the resolution strategy used by this configuration.
    `ResolvedConfiguration` | `getResolvedConfiguration()` | Resolves this configuration.
    `Configuration.State` | `getState()` | Returns the state of the configuration.
    `TaskDependency` | `getTaskDependencyFromProjectDependency​(boolean useDependedOn, String taskName)` | Returns a TaskDependency object containing dependencies on all tasks with the specified name from project dependencies related to this configuration or one of its super configurations.
    `String` | `getUploadTaskName()` | Deprecated.
    `boolean` | `isCanBeConsumed()` | Returns true if this configuration can be consumed from another project, or published.
    `boolean` | `isCanBeResolved()` | Returns true if it is allowed to query or resolve this configuration.
    `boolean` | `isTransitive()` | Returns the transitivity of this configuration.
    `boolean` | `isVisible()` | Returns true if this is a visible configuration.
    `void` | `outgoing​(Action<? super ConfigurationPublications> action)` | Configures the outgoing artifacts of this configuration.
    `Configuration` | `resolutionStrategy​(Closure closure)` | The resolution strategy provides extra details on how to resolve this configuration.
    `Configuration` | `resolutionStrategy​(Action<? super ResolutionStrategy> action)` | The resolution strategy provides extra details on how to resolve this configuration.
    `Set<File>` | `resolve()` | Resolves this configuration.
    `void` | `setCanBeConsumed​(boolean allowed)` | Configures if a configuration can be consumed.
    `void` | `setCanBeResolved​(boolean allowed)` | Configures if a configuration can be resolved.
    `Configuration` | `setDescription​(String description)` | Sets the description for this configuration.
    `Configuration` | `setExtendsFrom​(Iterable<Configuration> superConfigs)` | Sets the configurations which this configuration extends from.
    `Configuration` | `setTransitive​(boolean t)` | Sets the transitivity of this configuration.
    `Configuration` | `setVisible​(boolean visible)` | Sets the visibility of this configuration.
    `Configuration` | `shouldResolveConsistentlyWith​(Configuration versionsSource)` | Tells that this configuration, when resolved, should resolve versions consistently from the resolution result of another resolvable configuration.
    `Configuration` | `withDependencies​(Action<? super DependencySet> action)` | Execute the given action before the configuration first participates in dependency resolution.

    - ### Methods inherited from interface org.gradle.api.file.FileCollection

      `addToAntBuilder, addToAntBuilder, contains, filter, filter, getAsFileTree, getAsPath, getElements, getFiles, getSingleFile, isEmpty, minus, plus`

    - ### Methods inherited from interface org.gradle.api.attributes.HasAttributes

      `getAttributes`

    - ### Methods inherited from interface org.gradle.api.attributes.HasConfigurableAttributes

      `attributes`

    - ### Methods inherited from interface java.lang.Iterable

      `forEach, iterator, spliterator`

- - ### Method Detail

    - #### getResolutionStrategy

          ResolutionStrategy getResolutionStrategy()

      Returns the resolution strategy used by this configuration. The resolution strategy provides extra details on how to resolve this configuration. See docs for `ResolutionStrategy` for more info and examples.
      Returns:
        resolution strategy
      Since:
        1.0-milestone-6

    - #### resolutionStrategy

          Configuration resolutionStrategy​(@DelegatesTo(value=ResolutionStrategy.class,strategy=1)
                                           Closure closure)

      The resolution strategy provides extra details on how to resolve this configuration. See docs for `ResolutionStrategy` for more info and examples.
      Parameters:
        `closure` - closure applied to the `ResolutionStrategy`
      Returns:
        this configuration instance
      Since:
        1.0-milestone-6

    - #### resolutionStrategy

          Configuration resolutionStrategy​(Action<? super ResolutionStrategy> action)

      The resolution strategy provides extra details on how to resolve this configuration. See docs for `ResolutionStrategy` for more info and examples.
      Parameters:
        `action` - action applied to the `ResolutionStrategy`
      Returns:
        this configuration instance
      Since:
        3.1

    - #### getState

          Configuration.State getState()

      Returns the state of the configuration.
      Returns:
        The state of the configuration
      See Also:
        `Configuration.State`

    - #### getName

          String getName()

      Returns the name of this configuration.
      Returns:
        The configuration name, never null.

    - #### isVisible

          boolean isVisible()

      Returns true if this is a visible configuration. A visible configuration is usable outside the project it belongs to. The default value is true.
      Returns:
        true if this is a visible configuration.

    - #### setVisible

          Configuration setVisible​(boolean visible)

      Sets the visibility of this configuration. When visible is set to true, this configuration is visible outside the project it belongs to. The default value is true.
      Parameters:
        `visible` - true if this is a visible configuration
      Returns:
        this configuration

    - #### getExtendsFrom

          Set<Configuration> getExtendsFrom()

      Returns the names of the configurations which this configuration extends from. The artifacts of the super configurations are also available in this configuration.
      Returns:
        The super configurations. Returns an empty set when this configuration does not extend any others.

    - #### setExtendsFrom

          Configuration setExtendsFrom​(Iterable<Configuration> superConfigs)

      Sets the configurations which this configuration extends from.
      Parameters:
        `superConfigs` - The super configuration. Should not be null.
      Returns:
        this configuration

    - #### extendsFrom

          Configuration extendsFrom​(Configuration... superConfigs)

      Adds the given configurations to the set of configuration which this configuration extends from.
      Parameters:
        `superConfigs` - The super configurations.
      Returns:
        this configuration

    - #### isTransitive

          boolean isTransitive()

      Returns the transitivity of this configuration. A transitive configuration contains the transitive closure of its direct dependencies, and all their dependencies. An intransitive configuration contains only the direct dependencies. The default value is true.
      Returns:
        true if this is a transitive configuration, false otherwise.

    - #### setTransitive

          Configuration setTransitive​(boolean t)

      Sets the transitivity of this configuration. When set to true, this configuration will contain the transitive closure of its dependencies and their dependencies. The default value is true.
      Parameters:
        `t` - true if this is a transitive configuration.
      Returns:
        this configuration

    - #### getDescription

          @Nullable
          String getDescription()

      Returns the description for this configuration.
      Returns:
        the description. May be null.

    - #### setDescription

          Configuration setDescription​(@Nullable
                                       String description)

      Sets the description for this configuration.
      Parameters:
        `description` - the description. May be null
      Returns:
        this configuration

    - #### getHierarchy

          Set<Configuration> getHierarchy()

      Gets a ordered set including this configuration and all superconfigurations recursively.
      Returns:
        the list of all configurations

    - #### resolve

          Set<File> resolve()

      Resolves this configuration. This locates and downloads the files which make up this configuration, and returns the resulting set of files.
      Returns:
        The files of this configuration.

    - #### files

          Set<File> files​(Closure dependencySpecClosure)

      Takes a closure which gets coerced into a `Spec`. Behaves otherwise in the same way as `files(org.gradle.api.specs.Spec)`.
      Parameters:
        `dependencySpecClosure` - The closure describing a filter applied to the all the dependencies of this configuration (including dependencies from extended configurations).
      Returns:
        The files of a subset of dependencies of this configuration.

    - #### files

          Set<File> files​(Spec<? super Dependency> dependencySpec)

      Resolves this configuration. This locates and downloads the files which make up this configuration. But only the resulting set of files belonging to the subset of dependencies specified by the dependencySpec is returned.
      Parameters:
        `dependencySpec` - The spec describing a filter applied to the all the dependencies of this configuration (including dependencies from extended configurations).
      Returns:
        The files of a subset of dependencies of this configuration.

    - #### files

          Set<File> files​(Dependency... dependencies)

      Resolves this configuration. This locates and downloads the files which make up this configuration. But only the resulting set of files belonging to the specified dependencies is returned.
      Parameters:
        `dependencies` - The dependencies to be resolved
      Returns:
        The files of a subset of dependencies of this configuration.

    - #### fileCollection

          FileCollection fileCollection​(Spec<? super Dependency> dependencySpec)

      Resolves this configuration lazily. The resolve happens when the elements of the returned `FileCollection` get accessed the first time. This locates and downloads the files which make up this configuration. Only the resulting set of files belonging to the subset of dependencies specified by the dependencySpec is contained in the FileCollection.
      Parameters:
        `dependencySpec` - The spec describing a filter applied to the all the dependencies of this configuration (including dependencies from extended configurations).
      Returns:
        The FileCollection with a subset of dependencies of this configuration.

    - #### fileCollection

          FileCollection fileCollection​(Closure dependencySpecClosure)

      Takes a closure which gets coerced into a `Spec`. Behaves otherwise in the same way as `fileCollection(org.gradle.api.specs.Spec)`.
      Parameters:
        `dependencySpecClosure` - The closure describing a filter applied to the all the dependencies of this configuration (including dependencies from extended configurations).
      Returns:
        The FileCollection with a subset of dependencies of this configuration.

    - #### fileCollection

          FileCollection fileCollection​(Dependency... dependencies)

      Resolves this configuration lazily. The resolve happens when the elements of the returned `FileCollection` get accessed the first time. This locates and downloads the files which make up this configuration. Only the resulting set of files belonging to specified dependencies is contained in the FileCollection.
      Parameters:
        `dependencies` - The dependencies for which the FileCollection should contain the files.
      Returns:
        The FileCollection with a subset of dependencies of this configuration.

    - #### getResolvedConfiguration

          ResolvedConfiguration getResolvedConfiguration()

      Resolves this configuration. This locates and downloads the files which make up this configuration, and returns a `ResolvedConfiguration` that may be used to determine information about the resolve (including errors).
      Returns:
        The ResolvedConfiguration object

    - #### getUploadTaskName

          @Deprecated
          String getUploadTaskName()

      Deprecated.
      Returns the name of the task that upload the artifacts of this configuration to repositories declared by the user.
      Returns:
        The name of the associated upload task
      See Also:
        `Upload`

    - #### getBuildDependencies

          TaskDependency getBuildDependencies()

      Returns a `TaskDependency` object containing all required dependencies to build the local dependencies (e.g. project dependencies) belonging to this configuration or to one of its super configurations.
      Specified by:
        `getBuildDependencies` in interface `Buildable`
      Returns:
        a TaskDependency object

    - #### getTaskDependencyFromProjectDependency

          TaskDependency getTaskDependencyFromProjectDependency​(boolean useDependedOn,
                                                                String taskName)

      Returns a TaskDependency object containing dependencies on all tasks with the specified name from project dependencies related to this configuration or one of its super configurations. These other projects may be projects this configuration depends on or projects with a similarly named configuration that depend on this one based on the useDependOn argument.
      Parameters:
        `useDependedOn` - if true, add tasks from project dependencies in this configuration, otherwise use projects from configurations with the same name that depend on this one.
        `taskName` - name of task to depend on
      Returns:
        the populated TaskDependency object

    - #### getDependencies

          DependencySet getDependencies()

      Gets the set of declared dependencies directly contained in this configuration (ignoring superconfigurations).

      This method does not resolve the configuration. Therefore, the return value does not include transitive dependencies.

      Returns:
        the set of dependencies
      See Also:
        `extendsFrom(Configuration...)`

    - #### getAllDependencies

          DependencySet getAllDependencies()

      Gets the complete set of declared dependencies including those contributed by superconfigurations.

      This method does not resolve the configuration. Therefore, the return value does not include transitive dependencies.

      Returns:
        the (read-only) set of dependencies
      See Also:
        `extendsFrom(Configuration...)`

    - #### getDependencyConstraints

          DependencyConstraintSet getDependencyConstraints()

      Gets the set of dependency constraints directly contained in this configuration (ignoring superconfigurations).
      Returns:
        the set of dependency constraints
      Since:
        4.6

    - #### getAllDependencyConstraints

          DependencyConstraintSet getAllDependencyConstraints()

      Gets the complete set of dependency constraints including those contributed by superconfigurations.

      Returns:
        the (read-only) set of dependency constraints
      Since:
        4.6

    - #### getArtifacts

          PublishArtifactSet getArtifacts()

      Returns the artifacts of this configuration excluding the artifacts of extended configurations.
      Returns:
        The set.

    - #### getAllArtifacts

          PublishArtifactSet getAllArtifacts()

      Returns the artifacts of this configuration including the artifacts of extended configurations.
      Returns:
        The (read-only) set.

    - #### getExcludeRules

          Set<ExcludeRule> getExcludeRules()

      Returns the exclude rules applied for resolving any dependency of this configuration.
      Returns:
        The exclude rules
      See Also:
        `exclude(java.util.Map)`

    - #### exclude

          Configuration exclude​(Map<String,​String> excludeProperties)

      Adds an exclude rule to exclude transitive dependencies for all dependencies of this configuration. You can also add exclude rules per-dependency. See `ModuleDependency.exclude(java.util.Map)`.
      Parameters:
        `excludeProperties` - the properties to define the exclude rule.
      Returns:
        this

    - #### defaultDependencies

          Configuration defaultDependencies​(Action<? super DependencySet> action)

      Execute the given action if the configuration has no defined dependencies when it first participates in dependency resolution. A `Configuration` will participate in dependency resolution when:
      - The `Configuration` itself is resolved
      - Another `Configuration` that extends this one is resolved
      - Another `Configuration` that references this one as a project dependency is resolved
      This method is useful for specifying default dependencies for a configuration:

           configurations { conf }
           configurations['conf'].defaultDependencies { dependencies ->
                dependencies.add(owner.project.dependencies.create("org.gradle:my-util:1.0"))
           }

      A `Configuration` is considered empty even if it extends another, non-empty `Configuration`. If multiple actions are supplied, each action will be executed until the set of dependencies is no longer empty. Remaining actions will be ignored.
      Parameters:
        `action` - the action to execute when the configuration has no defined dependencies.
      Returns:
        this

    - #### withDependencies

          Configuration withDependencies​(Action<? super DependencySet> action)

      Execute the given action before the configuration first participates in dependency resolution. A `Configuration` will participate in dependency resolution when:
      - The `Configuration` itself is resolved
      - Another `Configuration` that extends this one is resolved
      - Another `Configuration` that references this one as a project dependency is resolved
      This method is useful for mutating the dependencies for a configuration:

           configurations { conf }
           configurations['conf'].withDependencies { dependencies ->
                dependencies.each { dependency ->
                    if (dependency.version == null) {
                        dependency.version { require '1.0' }
                    }
                }
           }

      Actions will be executed in the order provided.
      Parameters:
        `action` - a dependency action to execute before the configuration is used.
      Returns:
        this
      Since:
        4.4

    - #### getAll

          Set<Configuration> getAll()

      Returns all the configurations belonging to the same configuration container as this configuration (including this configuration).
      Returns:
        All of the configurations belong to the configuration container that this set belongs to.

    - #### getIncoming

          ResolvableDependencies getIncoming()

      Returns the incoming dependencies of this configuration.
      Returns:
        The incoming dependencies of this configuration. Never `null`.

    - #### getOutgoing

          ConfigurationPublications getOutgoing()

      Returns the outgoing artifacts of this configuration.
      Returns:
        The outgoing artifacts of this configuration.
      Since:
        3.4

    - #### outgoing

          void outgoing​(Action<? super ConfigurationPublications> action)

      Configures the outgoing artifacts of this configuration.
      Parameters:
        `action` - The action to perform the configuration.
      Since:
        3.4

    - #### copy

          Configuration copy()

      Creates a copy of this configuration that only contains the dependencies directly in this configuration (without contributions from superconfigurations). The new configuration will be in the UNRESOLVED state, but will retain all other attributes of this configuration except superconfigurations. `getHierarchy()` for the copy will not include any superconfigurations.
      Returns:
        copy of this configuration

    - #### copyRecursive

          Configuration copyRecursive()

      Creates a copy of this configuration that contains the dependencies directly in this configuration and those derived from superconfigurations. The new configuration will be in the UNRESOLVED state, but will retain all other attributes of this configuration except superconfigurations. `getHierarchy()` for the copy will not include any superconfigurations.
      Returns:
        copy of this configuration

    - #### copy

          Configuration copy​(Spec<? super Dependency> dependencySpec)

      Creates a copy of this configuration ignoring superconfigurations (see `copy()` but filtering the dependencies using the specified dependency spec.
      Parameters:
        `dependencySpec` - filtering requirements
      Returns:
        copy of this configuration

    - #### copyRecursive

          Configuration copyRecursive​(Spec<? super Dependency> dependencySpec)

      Creates a copy of this configuration with dependencies from superconfigurations (see `copyRecursive()`) but filtering the dependencies using the dependencySpec.
      Parameters:
        `dependencySpec` - filtering requirements
      Returns:
        copy of this configuration

    - #### copy

          Configuration copy​(Closure dependencySpec)

      Takes a closure which gets coerced into a `Spec`. Behaves otherwise in the same way as `copy(org.gradle.api.specs.Spec)`
      Parameters:
        `dependencySpec` - filtering requirements
      Returns:
        copy of this configuration

    - #### copyRecursive

          Configuration copyRecursive​(Closure dependencySpec)

      Takes a closure which gets coerced into a `Spec`. Behaves otherwise in the same way as `copyRecursive(org.gradle.api.specs.Spec)`
      Parameters:
        `dependencySpec` - filtering requirements
      Returns:
        copy of this configuration

    - #### setCanBeConsumed

          void setCanBeConsumed​(boolean allowed)

      Configures if a configuration can be consumed.
      Since:
        3.3

    - #### isCanBeConsumed

          boolean isCanBeConsumed()

      Returns true if this configuration can be consumed from another project, or published. Defaults to true.
      Returns:
        true if this configuration can be consumed or published.
      Since:
        3.3

    - #### setCanBeResolved

          void setCanBeResolved​(boolean allowed)

      Configures if a configuration can be resolved.
      Since:
        3.3

    - #### isCanBeResolved

          boolean isCanBeResolved()

      Returns true if it is allowed to query or resolve this configuration. Defaults to true.
      Returns:
        true if this configuration can be queried or resolved.
      Since:
        3.3

    - #### shouldResolveConsistentlyWith

          @Incubating
          Configuration shouldResolveConsistentlyWith​(Configuration versionsSource)

      Tells that this configuration, when resolved, should resolve versions consistently from the resolution result of another resolvable configuration. For example, it's expected that the versions of the runtime classpath are the same as the versions from the compile classpath.
      Parameters:
        `versionsSource` - another resolvable configuration to use as reference for versions
      Returns:
        this configuration
      Since:
        6.8

    - #### disableConsistentResolution

          @Incubating
          Configuration disableConsistentResolution()

      Disables consistent resolution for this configuration
      Since:
        6.8