Dependency
, HasAttributes
, HasConfigurableAttributes<ModuleDependency>
ClientModule
, ExternalDependency
, ExternalModuleDependency
, ProjectDependency
public interface ModuleDependency extends Dependency, HasConfigurableAttributes<ModuleDependency>
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)
.
ARCHIVES_CONFIGURATION, CLASSIFIER, DEFAULT_CONFIGURATION
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.
|
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 |
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.
|
because, contentEquals, getGroup, getName, getReason, getVersion
ModuleDependency exclude(Map<String,String> excludeProperties)
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...)
.
apply plugin: '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 } }
excludeProperties
- the properties to define the exclude rule.Set<ExcludeRule> getExcludeRules()
exclude(java.util.Map)
Set<DependencyArtifact> getArtifacts()
addArtifact(DependencyArtifact)
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.
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.
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.
boolean isTransitive()
setTransitive(boolean)
ModuleDependency setTransitive(boolean transitive)
transitive
- Whether transitive dependencies should be resolved.@Nullable String getTargetConfiguration()
null
, a default configuration should be used.@Incubating void setTargetConfiguration(@Nullable String name)
null
, a default configuration will be used.ModuleDependency copy()
copy
in interface Dependency
@Incubating AttributeContainer getAttributes()
attributes(Action)
method.getAttributes
in interface HasAttributes
@Incubating ModuleDependency attributes(Action<? super AttributeContainer> configureAction)
attributes
in interface HasConfigurableAttributes<ModuleDependency>
configureAction
- the attributes mutation action@Incubating ModuleDependency capabilities(Action<? super ModuleDependencyCapabilitiesHandler> configureAction)
configureAction
- the configuration action@Incubating List<Capability> getRequestedCapabilities()
capabilities(Action)
.