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 SummaryNested ClassesModifier and TypeClassDescriptionstatic classBuilder class used to create Dependency instances.
- 
Method SummaryModifier 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- 
getGroupIdThe project group that produced the dependency, e.g.org.apache.maven.- Returns:
- a String
 
- 
getArtifactIdThe unique id for an artifact produced by the project group, e.g.maven-artifact.- Returns:
- a String
 
- 
getVersionThe 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
 
- 
getTypeThe 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
 
- 
getClassifierThe 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 
- 
getScopeThe 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
 
- 
getSystemPathFOR 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
 
- 
getExclusionsLists 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>
 
- 
getOptionalIndicates 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
 
- 
getLocationGets the location of the specified field in the input source.- Specified by:
- getLocationin interface- InputLocationTracker
 
- 
withCreates a new builder with this object as the basis.- Returns:
- a Builder
 
- 
withGroupIdCreates a newDependencyinstance using the specified groupId.- Parameters:
- groupId- the new- Stringto use
- Returns:
- a Dependencywith the specified groupId
 
- 
withArtifactIdCreates a newDependencyinstance using the specified artifactId.- Parameters:
- artifactId- the new- Stringto use
- Returns:
- a Dependencywith the specified artifactId
 
- 
withVersionCreates a newDependencyinstance using the specified version.- Parameters:
- version- the new- Stringto use
- Returns:
- a Dependencywith the specified version
 
- 
withTypeCreates a newDependencyinstance using the specified type.- Parameters:
- type- the new- Stringto use
- Returns:
- a Dependencywith the specified type
 
- 
withClassifierCreates a newDependencyinstance using the specified classifier.- Parameters:
- classifier- the new- Stringto use
- Returns:
- a Dependencywith the specified classifier
 
- 
withScopeCreates a newDependencyinstance using the specified scope.- Parameters:
- scope- the new- Stringto use
- Returns:
- a Dependencywith the specified scope
 
- 
withSystemPathCreates a newDependencyinstance using the specified systemPath.- Parameters:
- systemPath- the new- Stringto use
- Returns:
- a Dependencywith the specified systemPath
 
- 
withExclusionsCreates a newDependencyinstance using the specified exclusions.- Parameters:
- exclusions- the new- Collection<Exclusion>to use
- Returns:
- a Dependencywith the specified exclusions
 
- 
withOptionalCreates a newDependencyinstance using the specified optional.- Parameters:
- optional- the new- Stringto use
- Returns:
- a Dependencywith the specified optional
 
- 
newInstanceCreates a newDependencyinstance. Equivalent tonewInstance(true).- Returns:
- a new Dependency
- See Also:
 
- 
newInstanceCreates 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
 
- 
newBuilderCreates a newDependencybuilder instance. Equivalent tonewBuilder(true).- Returns:
- a new Builder
- See Also:
 
- 
newBuilderCreates a newDependencybuilder instance using default values or not.- Parameters:
- withDefaults- the boolean indicating whether default values should be used
- Returns:
- a new Builder
 
- 
newBuilderCreates a newDependencybuilder instance using the specified object as a basis. Equivalent tonewBuilder(from, false).- Parameters:
- from- the- Dependencyinstance to use as a basis
- Returns:
- a new Builder
 
- 
newBuilderCreates a newDependencybuilder instance using the specified object as a basis.- Parameters:
- from- the- Dependencyinstance to use as a basis
- forceCopy- the boolean indicating if a copy should be forced
- Returns:
- a new Builder
 
- 
isOptionalpublic boolean isOptional()
- 
toString
- 
getManagementKey- Returns:
- the management key as groupId:artifactId:type
 
 
-