Package org.apache.maven.api.model
Class Dependency
java.lang.Object
org.apache.maven.api.model.Dependency
- All Implemented Interfaces:
Serializable,InputLocationTracker
@Experimental
@Generated
@ThreadSafe
@Immutable
public class Dependency
extends Object
implements Serializable, InputLocationTracker
The
<dependency> element contains information about a dependency
of the project.- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class used to create Dependency instances. -
Method Summary
Modifier and TypeMethodDescriptionThe unique id for an artifact produced by the project group, e.g.The classifier of the dependency.Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to calculating transitive dependencies.The project group that produced the dependency, e.g.getLocation(Object key) Gets the location of the specified field in the input source.Indicates the dependency is optional for use of this library.getScope()The scope of the dependency -compile,runtime,test,system, andprovided.FOR SYSTEM SCOPE ONLY.getType()The type of dependency, that will be mapped to a file extension, an optional classifier, and a few other attributes.The version of the dependency, e.g.booleanstatic Dependency.BuilderCreates a newDependencybuilder instance.static Dependency.BuildernewBuilder(boolean withDefaults) Creates a newDependencybuilder instance using default values or not.static Dependency.BuildernewBuilder(Dependency from) Creates a newDependencybuilder instance using the specified object as a basis.static Dependency.BuildernewBuilder(Dependency from, boolean forceCopy) Creates a newDependencybuilder instance using the specified object as a basis.static DependencyCreates a newDependencyinstance.static DependencynewInstance(boolean withDefaults) Creates a newDependencyinstance using default values or not.toString()with()Creates a new builder with this object as the basis.withArtifactId(String artifactId) Creates a newDependencyinstance using the specified artifactId.withClassifier(String classifier) Creates a newDependencyinstance using the specified classifier.withExclusions(Collection<Exclusion> exclusions) Creates a newDependencyinstance using the specified exclusions.withGroupId(String groupId) Creates a newDependencyinstance using the specified groupId.withOptional(String optional) Creates a newDependencyinstance using the specified optional.Creates a newDependencyinstance using the specified scope.withSystemPath(String systemPath) Creates a newDependencyinstance using the specified systemPath.Creates a newDependencyinstance using the specified type.withVersion(String version) Creates a newDependencyinstance using the specified version.
-
Method Details
-
getGroupId
The project group that produced the dependency, e.g.org.apache.maven.- Returns:
- a
String
-
getArtifactId
The unique id for an artifact produced by the project group, e.g.maven-artifact.- Returns:
- a
String
-
getVersion
The version of the dependency, e.g.3.2.1. In Maven 2, this can also be specified as a range of versions.- Returns:
- a
String
-
getType
The type of dependency, that will be mapped to a file extension, an optional classifier, and a few other attributes. Some examples arejar,war,ejb-clientandtest-jar: see default artifact handlers for a list. New types can be defined by extensions, so this is not a complete list.- Returns:
- a
String
-
getClassifier
The classifier of the dependency. It is appended to the filename after the version. This allows:- referring to attached artifact, for example
sourcesandjavadoc: see default artifact handlers for a list, - distinguishing two artifacts
that belong to the same POM but were built differently.
For example,
jdk14andjdk15.
- Returns:
- a
String
- referring to attached artifact, for example
-
getScope
The scope of the dependency -compile,runtime,test,system, andprovided. Used to calculate the various classpaths used for compilation, testing, and so on. It also assists in determining which artifacts to include in a distribution of this project. For more information, see the dependency mechanism. The default scope iscompile.- Returns:
- a
String
-
getSystemPath
FOR SYSTEM SCOPE ONLY. Note that use of this property is discouraged and may be replaced in later versions. This specifies the path on the filesystem for this dependency. Requires an absolute path for the value, not relative. Use a property that gives the machine specific absolute path, e.g.${java.home}.- Returns:
- a
String
-
getExclusions
Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to calculating transitive dependencies.- Returns:
- a
List<Exclusion>
-
getOptional
Indicates the dependency is optional for use of this library. While the version of the dependency will be taken into account for dependency calculation if the library is used elsewhere, it will not be passed on transitively. Note: While the type of this field isStringfor technical reasons, the semantic type is actuallyBoolean. Default value isfalse.- Returns:
- a
String
-
getLocation
Gets the location of the specified field in the input source.- Specified by:
getLocationin interfaceInputLocationTracker
-
with
Creates a new builder with this object as the basis.- Returns:
- a
Builder
-
withGroupId
Creates a newDependencyinstance using the specified groupId.- Parameters:
groupId- the newStringto use- Returns:
- a
Dependencywith the specified groupId
-
withArtifactId
Creates a newDependencyinstance using the specified artifactId.- Parameters:
artifactId- the newStringto use- Returns:
- a
Dependencywith the specified artifactId
-
withVersion
Creates a newDependencyinstance using the specified version.- Parameters:
version- the newStringto use- Returns:
- a
Dependencywith the specified version
-
withType
Creates a newDependencyinstance using the specified type.- Parameters:
type- the newStringto use- Returns:
- a
Dependencywith the specified type
-
withClassifier
Creates a newDependencyinstance using the specified classifier.- Parameters:
classifier- the newStringto use- Returns:
- a
Dependencywith the specified classifier
-
withScope
Creates a newDependencyinstance using the specified scope.- Parameters:
scope- the newStringto use- Returns:
- a
Dependencywith the specified scope
-
withSystemPath
Creates a newDependencyinstance using the specified systemPath.- Parameters:
systemPath- the newStringto use- Returns:
- a
Dependencywith the specified systemPath
-
withExclusions
Creates a newDependencyinstance using the specified exclusions.- Parameters:
exclusions- the newCollection<Exclusion>to use- Returns:
- a
Dependencywith the specified exclusions
-
withOptional
Creates a newDependencyinstance using the specified optional.- Parameters:
optional- the newStringto use- Returns:
- a
Dependencywith the specified optional
-
newInstance
Creates a newDependencyinstance. Equivalent tonewInstance(true).- Returns:
- a new
Dependency - See Also:
-
newInstance
Creates a newDependencyinstance using default values or not. Equivalent tonewBuilder(withDefaults).build().- Parameters:
withDefaults- the boolean indicating whether default values should be used- Returns:
- a new
Dependency
-
newBuilder
Creates a newDependencybuilder instance. Equivalent tonewBuilder(true).- Returns:
- a new
Builder - See Also:
-
newBuilder
Creates a newDependencybuilder instance using default values or not.- Parameters:
withDefaults- the boolean indicating whether default values should be used- Returns:
- a new
Builder
-
newBuilder
Creates a newDependencybuilder instance using the specified object as a basis. Equivalent tonewBuilder(from, false).- Parameters:
from- theDependencyinstance to use as a basis- Returns:
- a new
Builder
-
newBuilder
Creates a newDependencybuilder instance using the specified object as a basis.- Parameters:
from- theDependencyinstance to use as a basisforceCopy- the boolean indicating if a copy should be forced- Returns:
- a new
Builder
-
isOptional
public boolean isOptional() -
toString
-
getManagementKey
- Returns:
- the management key as
groupId:artifactId:type
-