Package org.eclipse.aether.graph
Class Dependency
- java.lang.Object
-
- org.eclipse.aether.graph.Dependency
-
public final class Dependency extends Object
A dependency to some artifact. Note: Instances of this class are immutable and the exposed mutators return new objects rather than changing the current instance.
-
-
Constructor Summary
Constructors Constructor Description Dependency(Artifact artifact, String scope)
Creates a mandatory dependency on the specified artifact with the given scope.Dependency(Artifact artifact, String scope, Boolean optional)
Creates a dependency on the specified artifact with the given scope.Dependency(Artifact artifact, String scope, Boolean optional, Collection<Exclusion> exclusions)
Creates a dependency on the specified artifact with the given scope and exclusions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Artifact
getArtifact()
Gets the artifact being depended on.Collection<Exclusion>
getExclusions()
Gets the exclusions for this dependency.Boolean
getOptional()
Gets the optional flag for the dependency.String
getScope()
Gets the scope of the dependency.int
hashCode()
boolean
isOptional()
Indicates whether this dependency is optional or not.Dependency
setArtifact(Artifact artifact)
Sets the artifact being depended on.Dependency
setExclusions(Collection<Exclusion> exclusions)
Sets the exclusions for the dependency.Dependency
setOptional(Boolean optional)
Sets the optional flag for the dependency.Dependency
setScope(String scope)
Sets the scope of the dependency, e.g.String
toString()
-
-
-
Constructor Detail
-
Dependency
public Dependency(Artifact artifact, String scope)
Creates a mandatory dependency on the specified artifact with the given scope.- Parameters:
artifact
- The artifact being depended on, must not benull
.scope
- The scope of the dependency, may benull
.
-
Dependency
public Dependency(Artifact artifact, String scope, Boolean optional)
Creates a dependency on the specified artifact with the given scope.- Parameters:
artifact
- The artifact being depended on, must not benull
.scope
- The scope of the dependency, may benull
.optional
- A flag whether the dependency is optional or mandatory, may benull
.
-
Dependency
public Dependency(Artifact artifact, String scope, Boolean optional, Collection<Exclusion> exclusions)
Creates a dependency on the specified artifact with the given scope and exclusions.- Parameters:
artifact
- The artifact being depended on, must not benull
.scope
- The scope of the dependency, may benull
.optional
- A flag whether the dependency is optional or mandatory, may benull
.exclusions
- The exclusions that apply to transitive dependencies, may benull
if none.
-
-
Method Detail
-
getArtifact
public Artifact getArtifact()
Gets the artifact being depended on.- Returns:
- The artifact, never
null
.
-
setArtifact
public Dependency setArtifact(Artifact artifact)
Sets the artifact being depended on.- Parameters:
artifact
- The artifact, must not benull
.- Returns:
- The new dependency, never
null
.
-
getScope
public String getScope()
Gets the scope of the dependency. The scope defines in which context this dependency is relevant.- Returns:
- The scope or an empty string if not set, never
null
.
-
setScope
public Dependency setScope(String scope)
Sets the scope of the dependency, e.g. "compile".- Parameters:
scope
- The scope of the dependency, may benull
.- Returns:
- The new dependency, never
null
.
-
isOptional
public boolean isOptional()
Indicates whether this dependency is optional or not. Optional dependencies can be ignored in some contexts.- Returns:
true
if the dependency is (definitively) optional,false
otherwise.
-
getOptional
public Boolean getOptional()
Gets the optional flag for the dependency. Note: Most clients will usually callisOptional()
to determine the optional flag, this method is for advanced use cases where three-valued logic is required.- Returns:
- The optional flag or
null
if unspecified.
-
setOptional
public Dependency setOptional(Boolean optional)
Sets the optional flag for the dependency.- Parameters:
optional
-true
if the dependency is optional,false
if the dependency is mandatory, may benull
if unspecified.- Returns:
- The new dependency, never
null
.
-
getExclusions
public Collection<Exclusion> getExclusions()
Gets the exclusions for this dependency. Exclusions can be used to remove transitive dependencies during resolution.- Returns:
- The (read-only) exclusions, never
null
.
-
setExclusions
public Dependency setExclusions(Collection<Exclusion> exclusions)
Sets the exclusions for the dependency.- Parameters:
exclusions
- The exclusions, may benull
.- Returns:
- The new dependency, never
null
.
-
-