api / org.gradle.api.artifacts / ExternalDependency

ExternalDependency

interface ExternalDependency : ModuleDependency, ModuleVersionSelector

An ExternalDependency is a Dependency on a source outside the current project hierarchy.

Functions

copy

abstract fun copy(): ExternalDependency

{@inheritDoc}

isForce

abstract fun isForce(): Boolean

Returns whether or not the version of this dependency should be enforced in the case of version conflicts.

setForce

abstract fun setForce(force: Boolean): ExternalDependency

Sets whether or not the version of this dependency should be enforced in the case of version conflicts.

version

abstract fun version(configureAction: Action<in MutableVersionConstraint>): Unit

Configures the version constraint for this dependency.

Inherited Functions

addArtifact

abstract fun addArtifact(artifact: DependencyArtifact): ModuleDependency

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.

artifact

abstract fun artifact(configureClosure: Closure<Any>): DependencyArtifact

Adds an artifact to this dependency. The given closure is passed a 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.

abstract fun artifact(configureAction: Action<in DependencyArtifact>): DependencyArtifact

Adds an artifact to this dependency. The given action is passed a 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.

attributes

abstract fun attributes(configureAction: Action<in AttributeContainer>): ModuleDependency

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.

exclude

abstract fun exclude(excludeProperties: MutableMap<String, String>): ModuleDependency

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...).

 apply plugin: 'java' //so that I can declare 'compile' dependencies dependencies { compile('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 } } 

getArtifacts

abstract fun getArtifacts(): MutableSet<DependencyArtifact>

Returns the artifacts belonging to this dependency.

getAttributes

abstract fun getAttributes(): AttributeContainer

Returns the attributes for this dependency. Mutation of the attributes of a dependency must be done through the #attributes(Action) method.

getExcludeRules

abstract fun getExcludeRules(): MutableSet<ExcludeRule>

Returns the exclude rules for this dependency.

getModule

abstract fun getModule(): ModuleIdentifier

The module identifier of the component. Returns the same information as #getGroup() and #getName().

getTargetConfiguration

abstract fun getTargetConfiguration(): String

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.

getVersionConstraint

abstract fun getVersionConstraint(): VersionConstraint

Returns the version constraint to be used during selection.

isTransitive

abstract fun isTransitive(): Boolean

Returns whether this dependency should be resolved including or excluding its transitive dependencies.

matchesStrictly

abstract fun matchesStrictly(identifier: ModuleVersionIdentifier): Boolean

To match strictly means that the given identifier needs to have equal group, module name and version. It does not smartly match dynamic versions, e.g. '1.+' selector does not strictly match '1.2' identifier.

setTargetConfiguration

abstract fun setTargetConfiguration(name: String): Unit

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.

setTransitive

abstract fun setTransitive(transitive: Boolean): ModuleDependency

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.

Inheritors

ExternalModuleDependency

interface ExternalModuleDependency : ExternalDependency

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