public class Dependency extends Object implements Comparable<Dependency>
Structured after the model used by Maven. This may be replaced in a future release with a more OSGi-centric model.
According to the Maven docs, "the minimal set of information for matching a dependency reference against a dependencyManagement section is actually {groupId, artifactId, type, classifier}"; see http://maven.apache.org/guides/introduction /introduction-to-dependency-mechanism.html#Dependency_Scope
| Constructor and Description |
|---|
Dependency(Element dependency)
Constructs a
Dependency from a Maven-style <dependency>
element. |
Dependency(GAV gav,
DependencyType type,
DependencyScope scope)
Constructor for a dependency with the given attributes.
|
Dependency(String groupId,
String artifactId,
String version)
Constructs a compile-scoped JAR dependency.
|
Dependency(String groupId,
String artifactId,
String version,
Collection<? extends Dependency> exclusions)
Constructs a compile-scoped JAR dependency with optional exclusions.
|
Dependency(String groupId,
String artifactId,
String version,
DependencyType type,
DependencyScope scope)
Constructs a dependency with the given type and scope.
|
Dependency(String groupId,
String artifactId,
String version,
DependencyType type,
DependencyScope scope,
String classifier)
Creates an immutable
Dependency. |
| Modifier and Type | Method and Description |
|---|---|
void |
addExclusion(String exclusionGroupId,
String exclusionArtifactId)
Adds the given exclusion to this dependency
|
int |
compareTo(Dependency o) |
boolean |
equals(Object obj) |
String |
getArtifactId() |
String |
getClassifier() |
Element |
getElement(Document document)
Returns the XML element for this dependency
|
List<Dependency> |
getExclusions() |
String |
getGroupId() |
DependencyScope |
getScope() |
String |
getSimpleDescription() |
String |
getSystemPath() |
DependencyType |
getType() |
String |
getVersion() |
String |
getVersionId()
Deprecated.
|
int |
hashCode() |
boolean |
hasSameCoordinates(Dependency dependency)
Indicates whether the given
Dependency has the same Maven
coordinates as this one; this is not necessarily the same as calling
equals(Object), which may compare more fields beyond the basic
coordinates. |
static boolean |
isHigherLevel(String type1,
String type2)
Indicates whether one dependency type is at a higher logical level than
another.
|
String |
toString() |
public Dependency(Element dependency)
Dependency from a Maven-style <dependency>
element.dependency - to parse (required)public Dependency(GAV gav, DependencyType type, DependencyScope scope)
gav - the coordinates to use (required)type - the dependency type (required)scope - the dependency scope (required)public Dependency(String groupId, String artifactId, String version)
groupId - the group ID (required)artifactId - the artifact ID (required)version - the version (required)public Dependency(String groupId, String artifactId, String version, Collection<? extends Dependency> exclusions)
groupId - the group ID (required)artifactId - the artifact ID (required)version - the version ID (required)exclusions - the exclusions for this dependency (can be null)public Dependency(String groupId, String artifactId, String version, DependencyType type, DependencyScope scope)
groupId - the group ID (required)artifactId - the artifact ID (required)version - the version ID (required)type - the dependency type (required)scope - the dependency scope (required)public Dependency(String groupId, String artifactId, String version, DependencyType type, DependencyScope scope, String classifier)
Dependency.groupId - the group ID (required)artifactId - the artifact ID (required)version - the version ID (required)type - the dependency type (required)scope - the dependency scope (required)classifier - the dependency classifier (required)public static boolean isHigherLevel(String type1, String type2)
type1 - the first dependency type to compare (required)type2 - the second dependency type to compare (required)false if they are at the same level or the first is
at a lower levelpublic void addExclusion(String exclusionGroupId, String exclusionArtifactId)
exclusionGroupId - the groupId of the dependency to exclude
(required)exclusionArtifactId - the artifactId of the dependency to exclude
(required)public int compareTo(Dependency o)
compareTo in interface Comparable<Dependency>public String getArtifactId()
public String getClassifier()
public Element getElement(Document document)
document - the parent XML documentnull elementpublic List<Dependency> getExclusions()
public String getGroupId()
public DependencyScope getScope()
public String getSimpleDescription()
public String getSystemPath()
public DependencyType getType()
public String getVersion()
@Deprecated public String getVersionId()
public boolean hasSameCoordinates(Dependency dependency)
Dependency has the same Maven
coordinates as this one; this is not necessarily the same as calling
equals(Object), which may compare more fields beyond the basic
coordinates.dependency - the dependency to check (can be null)false if any coordinates are differentCopyright © 2009–2017 Pivotal Software, Inc.. All rights reserved.