Package org.gradle.api.artifacts

## Interface ModuleDependency

- All Superinterfaces:
    `Dependency`, `HasAttributes`, `HasConfigurableAttributes<ModuleDependency>`
  All Known Subinterfaces:
    `ClientModule`, `ExternalDependency`, `ExternalModuleDependency`, `ProjectDependency`

      public interface ModuleDependency
      extends Dependency, HasConfigurableAttributes<ModuleDependency>

  A `ModuleDependency` is a `Dependency` on a module outside the current project.

  For examples on configuring the exclude rules please refer to `exclude(java.util.Map)`.

- - ### Field Summary

    - ### Fields inherited from interface org.gradle.api.artifacts.Dependency

      `ARCHIVES_CONFIGURATION, CLASSIFIER, DEFAULT_CONFIGURATION`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `ModuleDependency` | `addArtifact​(DependencyArtifact artifact)` | Adds an artifact to this dependency.
    `DependencyArtifact` | `artifact​(Closure configureClosure)` | Adds an artifact to this dependency.
    `DependencyArtifact` | `artifact​(Action<? super DependencyArtifact> configureAction)` | Adds an artifact to this dependency.
    `ModuleDependency` | `attributes​(Action<? super AttributeContainer> configureAction)` | Mutates the attributes of this dependency.
    `ModuleDependency` | `capabilities​(Action<? super ModuleDependencyCapabilitiesHandler> configureAction)` | Configures the requested capabilities of this dependency.
    `ModuleDependency` | `copy()` | Creates and returns a new dependency with the property values of this one.
    `void` | `doNotEndorseStrictVersions()` | Resets the `isEndorsingStrictVersions()` state of this dependency.
    `void` | `endorseStrictVersions()` | Endorse version constraints with `VersionConstraint.getStrictVersion()` strict versions} from the target module.
    `ModuleDependency` | `exclude​(Map<String,​String> excludeProperties)` | Adds an exclude rule to exclude transitive dependencies of this dependency.
    `Set<DependencyArtifact>` | `getArtifacts()` | Returns the artifacts belonging to this dependency.
    `AttributeContainer` | `getAttributes()` | Returns the attributes for this dependency.
    `Set<ExcludeRule>` | `getExcludeRules()` | Returns the exclude rules for this dependency.
    `List<Capability>` | `getRequestedCapabilities()` | Returns the set of requested capabilities for this dependency.
    `String` | `getTargetConfiguration()` | Returns the requested target configuration of this dependency.
    `boolean` | `isEndorsingStrictVersions()` | Are the `VersionConstraint.getStrictVersion()` strict version} dependency constraints of the target module endorsed?
    `boolean` | `isTransitive()` | Returns whether this dependency should be resolved including or excluding its transitive dependencies.
    `void` | `setTargetConfiguration​(String name)` | Sets the requested target configuration of this dependency.
    `ModuleDependency` | `setTransitive​(boolean transitive)` | Sets whether this dependency should be resolved including or excluding its transitive dependencies.

    - ### Methods inherited from interface org.gradle.api.artifacts.Dependency

      `because, contentEquals, getGroup, getName, getReason, getVersion`

- - ### Method Detail

    - #### exclude

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

      Adds an exclude rule to exclude transitive dependencies of this dependency.

      Excluding a particular transitive dependency does not guarantee that it does not show up in the dependencies of a given configuration. For example, some other dependency, which does not have any exclude rules, might pull in exactly the same transitive dependency. To guarantee that the transitive dependency is excluded from the entire configuration please use per-configuration exclude rules: `Configuration.getExcludeRules()`. In fact, in majority of cases the actual intention of configuring per-dependency exclusions is really excluding a dependency from the entire configuration (or classpath).

      If your intention is to exclude a particular transitive dependency because you don't like the version it pulls in to the configuration then consider using forced versions' feature: `ResolutionStrategy.force(Object...)`.

           plugins {
               id 'java' // so that I can declare 'implementation' dependencies
           }

           dependencies {
             implementation('org.hibernate:hibernate:3.1') {
               //excluding a particular transitive dependency:
               exclude module: 'cglib' //by artifact name
               exclude group: 'org.jmock' //by group
               exclude group: 'org.unwanted', module: 'iAmBuggy' //by both name and group
             }
           }

      Parameters:
        `excludeProperties` - the properties to define the exclude rule.
      Returns:
        this

    - #### getExcludeRules

          Set<ExcludeRule> getExcludeRules()

      Returns the exclude rules for this dependency.
      See Also:
        `exclude(java.util.Map)`

    - #### getArtifacts

          Set<DependencyArtifact> getArtifacts()

      Returns the artifacts belonging to this dependency.
      See Also:
        `addArtifact(DependencyArtifact)`

    - #### addArtifact

          ModuleDependency addArtifact​(DependencyArtifact artifact)

      Adds an artifact to this dependency.

      If no artifact is added to a dependency, an implicit default artifact is used. This default artifact has the same name as the module and its type and extension is `jar`. If at least one artifact is explicitly added, the implicit default artifact won't be used any longer.

      Returns:
        this

    - #### artifact

          DependencyArtifact artifact​(@DelegatesTo(value=DependencyArtifact.class,strategy=1)
                                      Closure configureClosure)

      Adds an artifact to this dependency. The given closure is passed a `DependencyArtifact` instance, which it can configure.

      If no artifact is added to a dependency, an implicit default artifact is used. This default artifact has the same name as the module and its type and extension is `jar`. If at least one artifact is explicitly added, the implicit default artifact won't be used any longer.

      Returns:
        the added artifact
      See Also:
        `DependencyArtifact`

    - #### artifact

          DependencyArtifact artifact​(Action<? super DependencyArtifact> configureAction)

      Adds an artifact to this dependency. The given action is passed a `DependencyArtifact` instance, which it can configure.

      If no artifact is added to a dependency, an implicit default artifact is used. This default artifact has the same name as the module and its type and extension is `jar`. If at least one artifact is explicitly added, the implicit default artifact won't be used any longer.

      Returns:
        the added artifact
      Since:
        3.1
      See Also:
        `DependencyArtifact`

    - #### isTransitive

          boolean isTransitive()

      Returns whether this dependency should be resolved including or excluding its transitive dependencies.
      See Also:
        `setTransitive(boolean)`

    - #### setTransitive

          ModuleDependency setTransitive​(boolean transitive)

      Sets whether this dependency should be resolved including or excluding its transitive dependencies. The artifacts belonging to this dependency might themselves have dependencies on other artifacts. The latter are called transitive dependencies.
      Parameters:
        `transitive` - Whether transitive dependencies should be resolved.
      Returns:
        this

    - #### getTargetConfiguration

          @Nullable
          String getTargetConfiguration()

      Returns the requested target configuration of this dependency. This is the name of the configuration in the target module that should be used when selecting the matching configuration. If `null`, a default configuration should be used.

    - #### setTargetConfiguration

          void setTargetConfiguration​(@Nullable
                                      String name)

      Sets the requested target configuration of this dependency. This is the name of the configuration in the target module that should be used when selecting the matching configuration. If `null`, a default configuration will be used.
      Since:
        4.0

    - #### copy

          ModuleDependency copy()

      Creates and returns a new dependency with the property values of this one.
      Specified by:
        `copy` in interface `Dependency`
      Returns:
        The copy. Never returns null.

    - #### getAttributes

          AttributeContainer getAttributes()

      Returns the attributes for this dependency. Mutation of the attributes of a dependency must be done through the `attributes(Action)` method.
      Specified by:
        `getAttributes` in interface `HasAttributes`
      Returns:
        the attributes container for this dependency
      Since:
        4.8

    - #### attributes

          ModuleDependency attributes​(Action<? super AttributeContainer> configureAction)

      Mutates the attributes of this dependency. Attributes are used during dependency resolution to select the appropriate target variant, in particular when a single component provides different variants.
      Specified by:
        `attributes` in interface `HasConfigurableAttributes<ModuleDependency>`
      Parameters:
        `configureAction` - the attributes mutation action
      Returns:
        this
      Since:
        4.8

    - #### capabilities

          ModuleDependency capabilities​(Action<? super ModuleDependencyCapabilitiesHandler> configureAction)

      Configures the requested capabilities of this dependency.
      Parameters:
        `configureAction` - the configuration action
      Returns:
        this
      Since:
        5.3

    - #### getRequestedCapabilities

          List<Capability> getRequestedCapabilities()

      Returns the set of requested capabilities for this dependency.
      Returns:
        An immutable view of requested capabilities. Updates must be done calling `capabilities(Action)`.
      Since:
        5.3

    - #### endorseStrictVersions

          void endorseStrictVersions()

      Endorse version constraints with `VersionConstraint.getStrictVersion()` strict versions} from the target module. Endorsing strict versions of another module/platform means that all strict versions will be interpreted during dependency resolution as if they where defined by the endorsing module itself.
      Since:
        6.0

    - #### doNotEndorseStrictVersions

          void doNotEndorseStrictVersions()

      Resets the `isEndorsingStrictVersions()` state of this dependency.
      Since:
        6.0

    - #### isEndorsingStrictVersions

          boolean isEndorsingStrictVersions()

      Are the `VersionConstraint.getStrictVersion()` strict version} dependency constraints of the target module endorsed?
      Since:
        6.0