Interface ModuleDependency
- All Superinterfaces:
- Dependency,- HasAttributes,- HasConfigurableAttributes<ModuleDependency>
- All Known Subinterfaces:
- ClientModule,- ExternalDependency,- ExternalModuleDependency,- MinimalExternalModuleDependency,- ProjectDependency
ModuleDependency is a Dependency on a component that exists
 outside of the current project.
 
 Modules can supply multiple artifacts in addition to the
 implicit default artifact.  Non-default artifacts
 available in a module can be selected by a consumer by specifying a classifier or extension
 when declaring a dependency on that module.
 
 For examples on configuring exclude rules for modules please refer to exclude(java.util.Map).
- 
Field SummaryFields inherited from interface org.gradle.api.artifacts.DependencyARCHIVES_CONFIGURATION, CLASSIFIER, DEFAULT_CONFIGURATION
- 
Method SummaryModifier and TypeMethodDescriptionaddArtifact(DependencyArtifact artifact) Adds an artifact to this dependency.Adds an artifact to this dependency.artifact(Action<? super DependencyArtifact> configureAction) Adds an artifact to this dependency.attributes(Action<? super AttributeContainer> configureAction) Mutates the attributes of this dependency.capabilities(Action<? super ModuleDependencyCapabilitiesHandler> configureAction) Configures the requested capabilities of this dependency.copy()Creates and returns a new dependency with the property values of this one.voidResets theisEndorsingStrictVersions()state of this dependency.voidEndorse version constraints withVersionConstraint.getStrictVersion()strict versions} from the target module.Adds an exclude rule to exclude transitive dependencies of this dependency.Returns the artifacts belonging to this dependency.Returns the attributes for this dependency.Returns the set of capabilities that are requested for this dependencyReturns the exclude rules for this dependency.Returns the explicitly requested capabilities for this dependency.Returns the requested target configuration of this dependency.booleanAre theVersionConstraint.getStrictVersion()strict version} dependency constraints of the target module endorsed?booleanReturns whether this dependency should be resolved including or excluding its transitive dependencies.voidsetTargetConfiguration(String name) Sets the requested target configuration of this dependency.setTransitive(boolean transitive) Sets whether this dependency should be resolved including or excluding its transitive dependencies.Methods inherited from interface org.gradle.api.artifacts.Dependencybecause, contentEquals, getGroup, getName, getReason, getVersion
- 
Method Details- 
excludeAdds 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 a 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
 
- 
getExcludeRulesSet<ExcludeRule> getExcludeRules()Returns the exclude rules for this dependency.- See Also:
 
- 
getArtifactsSet<DependencyArtifact> getArtifacts()Returns the artifacts belonging to this dependency.Initially, a dependency has no artifacts, so this can return an empty set. Typically, however, a producer project will add a single artifact to a module, which will be represented in this collection via a single element. But this is NOT always true. Modules can use custom classifiers or extensions to distinguish multiple artifacts that they contain. In general, projects publishing using Gradle should favor supplying multiple artifacts by supplying multiple variants, each containing a different artifact, that are selectable through variant-aware dependency resolution. This mechanism where a module contains multiple artifacts is primarily intended to support dependencies on non-Gradle-published components. - See Also:
 
- 
addArtifactAdds 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
 
- 
artifactDependencyArtifact artifact(@DelegatesTo(value=DependencyArtifact.class,strategy=1) Closure configureClosure) Adds an artifact to this dependency. The given closure is passed a DependencyArtifactinstance, 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:
 
- 
artifactAdds an artifact to this dependency. The given action is passed a DependencyArtifactinstance, 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:
 
- 
isTransitiveboolean isTransitive()Returns whether this dependency should be resolved including or excluding its transitive dependencies.- See Also:
 
- 
setTransitiveSets 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
 
- 
getTargetConfigurationReturns the requested target configuration of this dependency.If non-null, this overrides variant-aware dependency resolution and selects the variant in the target component matching the requested configuration name. 
- 
setTargetConfigurationSets the requested target configuration of this dependency.This overrides variant-aware dependency resolution and selects the variant in the target component matching the requested configuration name. Using this method is discouraged except for selecting configurations from Ivy components. - Since:
- 4.0
 
- 
copyModuleDependency copy()Creates and returns a new dependency with the property values of this one.- Specified by:
- copyin interface- Dependency
- Returns:
- The copy. Never returns null.
 
- 
getAttributesAttributeContainer getAttributes()Returns the attributes for this dependency. Mutation of the attributes of a dependency must be done through theattributes(Action)method.- Specified by:
- getAttributesin interface- HasAttributes
- Returns:
- the attributes container for this dependency
- Since:
- 4.8
 
- 
attributesMutates 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:
- attributesin interface- HasConfigurableAttributes<ModuleDependency>
- Parameters:
- configureAction- the attributes mutation action
- Returns:
- this
- Since:
- 4.8
 
- 
capabilitiesConfigures the requested capabilities of this dependency.- Parameters:
- configureAction- the configuration action
- Returns:
- this
- Since:
- 5.3
 
- 
getRequestedCapabilitiesList<Capability> getRequestedCapabilities()Returns the explicitly requested capabilities for this dependency.Prefer getCapabilitySelectors(). This method is not Isolated Projects compatible.- Returns:
- An immutable view of all explicitly requested capabilities. Updates must be done calling capabilities(Action).
- Since:
- 5.3
 
- 
getCapabilitySelectorsReturns the set of capabilities that are requested for this dependency- Returns:
- A view of all requested capabilities. Updates must be done calling capabilities(Action).
- Since:
- 8.11
 
- 
endorseStrictVersionsvoid endorseStrictVersions()Endorse version constraints withVersionConstraint.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 were defined by the endorsing module itself.- Since:
- 6.0
 
- 
doNotEndorseStrictVersionsvoid doNotEndorseStrictVersions()Resets theisEndorsingStrictVersions()state of this dependency.- Since:
- 6.0
 
- 
isEndorsingStrictVersionsboolean isEndorsingStrictVersions()Are theVersionConstraint.getStrictVersion()strict version} dependency constraints of the target module endorsed?- Since:
- 6.0
 
 
-