Package org.gradle.api.artifacts.dsl

# Interface DependencyCollector

@ManagedType @NonExtensible public interface DependencyCollector
A `DependencyCollector` is used as part of a dependencies block in the DSL. A collector implements a single dependency scope and exposes the declared dependencies on `getDependencies()`.

To use a `DependencyCollector` as a source of dependencies, wire it to the appropriate `Configuration` with `Configuration.fromDependencyCollector(DependencyCollector)`. Dependencies will be queried lazily.

Note: No mutations will be allowed after dependencies are read from a `DependencyCollector`.

Since:
  8.6
See Also:
  - `Create an instance of this as a managed property (preferred).`
API Note:
  Gradle has specific extensions to make explicit calls to `add(...)` unnecessary from the DSL.
  - For Groovy DSL, we create `call(...)` equivalents for all the `add(...)` methods.
  - For Kotlin DSL, we create `invoke(...)` equivalents for all the `add(...)` methods.
Implementation Requirements:
  This interface should not be implemented by end users or plugins.
Implementation Note:
  Changes to this interface may require changes to the `extension module for Groovy DSL` or `extension functions for Kotlin DSL`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<D extends Dependency>
  void`
  `add(D dependency, Action<? super D> configuration)`
  Add a dependency and configure it.
  `void`
  `add(CharSequence dependencyNotation)`
  Add a dependency.
  `void`
  `add(CharSequence dependencyNotation, Action<? super ExternalModuleDependency> configuration)`
  Add a dependency and configure it.
  `void`
  `add(Dependency dependency)`
  Add a dependency.
  `void`
  `add(FileCollection files)`
  Add a dependency.
  `void`
  `add(FileCollection files, Action<? super FileCollectionDependency> configuration)`
  Add a dependency and configure it.
  `<D extends Dependency>
  void`
  `add(Provider<? extends D> dependency, Action<? super D> configuration)`
  Add a dependency and configure it.
  `void`
  `add(Provider<? extends Dependency> dependency)`
  Add a dependency.
  `void`
  `add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule)`
  Add a dependency.
  `void`
  `add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule, Action<? super ExternalModuleDependency> configuration)`
  Add a dependency and configure it.
  `void`
  `addConstraint(DependencyConstraint dependencyConstraint)`
  Add a dependency constraint.
  `void`
  `addConstraint(DependencyConstraint dependencyConstraint, Action<? super DependencyConstraint> configuration)`
  Add a dependency constraint and configure it.
  `void`
  `addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint)`
  Add a dependency constraint, using a `Provider` to lazily create the constraint.
  `void`
  `addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint, Action<? super DependencyConstraint> configuration)`
  Add a dependency constraint and configure it, using a `Provider` to lazily create the constraint.
  `<D extends Dependency>
  void`
  `bundle(Iterable<? extends D> bundle)`
  Add a bundle.
  `<D extends Dependency>
  void`
  `bundle(Iterable<? extends D> bundle, Action<? super D> configuration)`
  Add a bundle and configure them.
  `<D extends Dependency>
  void`
  `bundle(Provider<? extends Iterable<? extends D>> bundle)`
  Add a bundle.
  `<D extends Dependency>
  void`
  `bundle(Provider<? extends Iterable<? extends D>> bundle, Action<? super D> configuration)`
  Add a bundle and configure them.
  `<D extends Dependency>
  void`
  `bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle)`
  Add a bundle.
  `<D extends Dependency>
  void`
  `bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle, Action<? super D> configuration)`
  Add a bundle and configure them.
  `Provider<Set<Dependency>>`
  `getDependencies()`
  Returns all dependencies declared on this collector.
  `Provider<Set<DependencyConstraint>>`
  `getDependencyConstraints()`
  Returns all dependency constraints declared on this collector.

- ## Method Details

  - ### add

    void add(CharSequence dependencyNotation)
    Add a dependency.
    Parameters:
      `dependencyNotation` - dependency to add
    Since:
      8.6
    See Also:
      - `Valid dependency notation for this method`

  - ### add

    void add(CharSequence dependencyNotation, Action<? super ExternalModuleDependency> configuration)
    Add a dependency and configure it.
    Parameters:
      `dependencyNotation` - dependency to add
      `configuration` - an action to configure the dependency
    Since:
      8.6
    See Also:
      - `Valid dependency notation for this method`

  - ### add

    void add(FileCollection files)
    Add a dependency.
    Parameters:
      `files` - files to add as a dependency
    Since:
      8.6
    See Also:
      - `DependencyFactory.create(FileCollection)`

  - ### add

    void add(FileCollection files, Action<? super FileCollectionDependency> configuration)
    Add a dependency and configure it.
    Parameters:
      `files` - files to add as a dependency
      `configuration` - an action to configure the dependency
    Since:
      8.6
    See Also:
      - `DependencyFactory.create(FileCollection)`

  - ### add

    @Incubating void add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule)
    Add a dependency.
    Parameters:
      `externalModule` - external module to add as a dependency
    Since:
      8.6

  - ### add

    @Incubating void add(ProviderConvertible<? extends MinimalExternalModuleDependency> externalModule, Action<? super ExternalModuleDependency> configuration)
    Add a dependency and configure it.
    Parameters:
      `externalModule` - external module to add as a dependency
      `configuration` - an action to configure the dependency
    Since:
      8.6

  - ### add

    void add(Dependency dependency)
    Add a dependency.
    Parameters:
      `dependency` - dependency to add
    Since:
      8.6

  - ### add

    <D extends Dependency> void add(D dependency, Action<? super D> configuration)
    Add a dependency and configure it.
    Parameters:
      `dependency` - dependency to add
      `configuration` - an action to configure the dependency
    Since:
      8.6

  - ### add

    void add(Provider<? extends Dependency> dependency)
    Add a dependency.
    Parameters:
      `dependency` - dependency to add
    Since:
      8.6

  - ### add

    <D extends Dependency> void add(Provider<? extends D> dependency, Action<? super D> configuration)
    Add a dependency and configure it.
    Parameters:
      `dependency` - dependency to add
      `configuration` - an action to configure the dependency
    Since:
      8.6

  - ### addConstraint

    void addConstraint(DependencyConstraint dependencyConstraint)
    Add a dependency constraint.
    Parameters:
      `dependencyConstraint` - dependency constraint to add
    Since:
      8.7

  - ### addConstraint

    void addConstraint(DependencyConstraint dependencyConstraint, Action<? super DependencyConstraint> configuration)
    Add a dependency constraint and configure it.
    Parameters:
      `dependencyConstraint` - dependency constraint to add
      `configuration` - an action to configure the dependency constraint
    Since:
      8.7

  - ### addConstraint

    void addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint)
    Add a dependency constraint, using a `Provider` to lazily create the constraint.
    Parameters:
      `dependencyConstraint` - dependency constraint to add
    Since:
      8.7

  - ### addConstraint

    void addConstraint(Provider<? extends DependencyConstraint> dependencyConstraint, Action<? super DependencyConstraint> configuration)
    Add a dependency constraint and configure it, using a `Provider` to lazily create the constraint.
    Parameters:
      `dependencyConstraint` - dependency constraint to add
      `configuration` - an action to configure the dependency constraint
    Since:
      8.7

  - ### bundle

    @Incubating <D extends Dependency> void bundle(Iterable<? extends D> bundle)
    Add a bundle.
    Parameters:
      `bundle` - the bundle to add
    Since:
      8.6

  - ### bundle

    @Incubating <D extends Dependency> void bundle(Iterable<? extends D> bundle, Action<? super D> configuration)
    Add a bundle and configure them.
    Parameters:
      `bundle` - the bundle to add
      `configuration` - an action to configure each dependency in the bundle
    Since:
      8.6

  - ### bundle

    @Incubating <D extends Dependency> void bundle(Provider<? extends Iterable<? extends D>> bundle)
    Add a bundle.
    Parameters:
      `bundle` - the bundle to add
    Since:
      8.6

  - ### bundle

    @Incubating <D extends Dependency> void bundle(Provider<? extends Iterable<? extends D>> bundle, Action<? super D> configuration)
    Add a bundle and configure them.
    Parameters:
      `bundle` - the bundle to add
      `configuration` - an action to configure each dependency in the bundle
    Since:
      8.6

  - ### bundle

    @Incubating <D extends Dependency> void bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle)
    Add a bundle.
    Parameters:
      `bundle` - the bundle to add
    Since:
      8.6

  - ### bundle

    @Incubating <D extends Dependency> void bundle(ProviderConvertible<? extends Iterable<? extends D>> bundle, Action<? super D> configuration)
    Add a bundle and configure them.
    Parameters:
      `bundle` - the bundle to add
      `configuration` - an action to configure each dependency in the bundle
    Since:
      8.6

  - ### getDependencies

    Provider<Set<Dependency>> getDependencies()
    Returns all dependencies declared on this collector.
    Since:
      8.6

  - ### getDependencyConstraints

    Provider<Set<DependencyConstraint>> getDependencyConstraints()
    Returns all dependency constraints declared on this collector.
    Since:
      8.7