Package org.apache.maven.model
Class Dependency
- java.lang.Object
-
- org.apache.maven.model.Dependency
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,InputLocationTracker
public class Dependency extends java.lang.Object implements java.io.Serializable, java.lang.Cloneable, InputLocationTracker
The<dependency>element contains information about a dependency of the project.- Version:
- $Revision$ $Date$
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringartifactIdThe unique id for an artifact produced by the project group, e.g.private InputLocationartifactIdLocationField artifactIdLocation.private java.lang.StringclassifierThe classifier of the dependency.private InputLocationclassifierLocationField classifierLocation.private java.util.List<Exclusion>exclusionsField exclusions.private InputLocationexclusionsLocationField exclusionsLocation.private java.lang.StringgroupIdThe project group that produced the dependency, e.g.private InputLocationgroupIdLocationField groupIdLocation.private InputLocationlocationField location.private java.util.Map<java.lang.Object,InputLocation>locationsField locations.private java.lang.StringmanagementKeyprivate java.lang.StringoptionalIndicates the dependency is optional for use of this library.private InputLocationoptionalLocationField optionalLocation.private java.lang.StringscopeThe scope of the dependency -compile,runtime,test,system, andprovided.private InputLocationscopeLocationField scopeLocation.private java.lang.StringsystemPathFOR SYSTEM SCOPE ONLY.private InputLocationsystemPathLocationField systemPathLocation.private java.lang.StringtypeThe type of dependency, that will be mapped to a file extension, an optional classifier, and a few other attributes.private InputLocationtypeLocationField typeLocation.private java.lang.StringversionThe version of the dependency, e.g.private InputLocationversionLocationField versionLocation.
-
Constructor Summary
Constructors Constructor Description Dependency()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddExclusion(Exclusion exclusion)Method addExclusion.voidclearManagementKey()Clears the management key in case one field has been modified.Dependencyclone()Method clone.java.lang.StringgetArtifactId()Get the unique id for an artifact produced by the project group, e.g.java.lang.StringgetClassifier()Get the classifier of the dependency.java.util.List<Exclusion>getExclusions()Method getExclusions.java.lang.StringgetGroupId()Get the project group that produced the dependency, e.g.InputLocationgetLocation(java.lang.Object key)Gets the location of the specified field in the input source.java.lang.StringgetManagementKey()java.lang.StringgetOptional()Get indicates the dependency is optional for use of this library.private InputLocationgetOtherLocation(java.lang.Object key)java.lang.StringgetScope()Get the scope of the dependency -compile,runtime,test,system, andprovided.java.lang.StringgetSystemPath()Get fOR SYSTEM SCOPE ONLY.java.lang.StringgetType()Get the type of dependency, that will be mapped to a file extension, an optional classifier, and a few other attributes.java.lang.StringgetVersion()Get the version of the dependency, e.g.booleanisOptional()voidremoveExclusion(Exclusion exclusion)Method removeExclusion.voidsetArtifactId(java.lang.String artifactId)Set the unique id for an artifact produced by the project group, e.g.voidsetClassifier(java.lang.String classifier)Set the classifier of the dependency.voidsetExclusions(java.util.List<Exclusion> exclusions)Set lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to calculating transitive dependencies.voidsetGroupId(java.lang.String groupId)Set the project group that produced the dependency, e.g.voidsetLocation(java.lang.Object key, InputLocation location)Sets the location of the specified field.voidsetOptional(boolean optional)voidsetOptional(java.lang.String optional)Set indicates the dependency is optional for use of this library.voidsetOtherLocation(java.lang.Object key, InputLocation location)voidsetScope(java.lang.String scope)Set the scope of the dependency -compile,runtime,test,system, andprovided.voidsetSystemPath(java.lang.String systemPath)Set fOR SYSTEM SCOPE ONLY.voidsetType(java.lang.String type)Set the type of dependency, that will be mapped to a file extension, an optional classifier, and a few other attributes.voidsetVersion(java.lang.String version)Set the version of the dependency, e.g.java.lang.StringtoString()
-
-
-
Field Detail
-
groupId
private java.lang.String groupId
The project group that produced the dependency, e.g.org.apache.maven.
-
artifactId
private java.lang.String artifactId
The unique id for an artifact produced by the project group, e.g.maven-artifact.
-
version
private java.lang.String version
The version of the dependency, e.g.3.2.1. In Maven 2, this can also be specified as a range of versions.
-
type
private java.lang.String type
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.
-
classifier
private java.lang.String classifier
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.
- referring to attached artifact, for example
-
scope
private java.lang.String scope
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.
-
systemPath
private java.lang.String systemPath
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}.
-
exclusions
private java.util.List<Exclusion> exclusions
Field exclusions.
-
optional
private java.lang.String optional
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.
-
locations
private java.util.Map<java.lang.Object,InputLocation> locations
Field locations.
-
location
private InputLocation location
Field location.
-
groupIdLocation
private InputLocation groupIdLocation
Field groupIdLocation.
-
artifactIdLocation
private InputLocation artifactIdLocation
Field artifactIdLocation.
-
versionLocation
private InputLocation versionLocation
Field versionLocation.
-
typeLocation
private InputLocation typeLocation
Field typeLocation.
-
classifierLocation
private InputLocation classifierLocation
Field classifierLocation.
-
scopeLocation
private InputLocation scopeLocation
Field scopeLocation.
-
systemPathLocation
private InputLocation systemPathLocation
Field systemPathLocation.
-
exclusionsLocation
private InputLocation exclusionsLocation
Field exclusionsLocation.
-
optionalLocation
private InputLocation optionalLocation
Field optionalLocation.
-
managementKey
private java.lang.String managementKey
-
-
Method Detail
-
addExclusion
public void addExclusion(Exclusion exclusion)
Method addExclusion.- Parameters:
exclusion-
-
clone
public Dependency clone()
Method clone.- Overrides:
clonein classjava.lang.Object- Returns:
- Dependency
-
getArtifactId
public java.lang.String getArtifactId()
Get the unique id for an artifact produced by the project group, e.g.maven-artifact.- Returns:
- String
-
getClassifier
public java.lang.String getClassifier()
Get 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:
- String
- referring to attached artifact, for example
-
getExclusions
public java.util.List<Exclusion> getExclusions()
Method getExclusions.- Returns:
- List
-
getGroupId
public java.lang.String getGroupId()
Get the project group that produced the dependency, e.g.org.apache.maven.- Returns:
- String
-
getLocation
public InputLocation getLocation(java.lang.Object key)
Description copied from interface:InputLocationTrackerGets the location of the specified field in the input source.- Specified by:
getLocationin interfaceInputLocationTracker- Parameters:
key-- Returns:
- InputLocation
-
getOptional
public java.lang.String getOptional()
Get 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:
- String
-
setLocation
public void setLocation(java.lang.Object key, InputLocation location)Description copied from interface:InputLocationTrackerSets the location of the specified field.- Specified by:
setLocationin interfaceInputLocationTracker- Parameters:
key-location-
-
setOtherLocation
public void setOtherLocation(java.lang.Object key, InputLocation location)- Parameters:
key-location-
-
getOtherLocation
private InputLocation getOtherLocation(java.lang.Object key)
- Parameters:
key-- Returns:
- InputLocation
-
getScope
public java.lang.String getScope()
Get 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:
- String
-
getSystemPath
public java.lang.String getSystemPath()
Get 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:
- String
-
getType
public java.lang.String getType()
Get 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:
- String
-
getVersion
public java.lang.String getVersion()
Get the version of the dependency, e.g.3.2.1. In Maven 2, this can also be specified as a range of versions.- Returns:
- String
-
removeExclusion
public void removeExclusion(Exclusion exclusion)
Method removeExclusion.- Parameters:
exclusion-
-
setArtifactId
public void setArtifactId(java.lang.String artifactId)
Set the unique id for an artifact produced by the project group, e.g.maven-artifact.- Parameters:
artifactId-
-
setClassifier
public void setClassifier(java.lang.String classifier)
Set 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.
- Parameters:
classifier-
- referring to attached artifact, for example
-
setExclusions
public void setExclusions(java.util.List<Exclusion> exclusions)
Set lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to calculating transitive dependencies.- Parameters:
exclusions-
-
setGroupId
public void setGroupId(java.lang.String groupId)
Set the project group that produced the dependency, e.g.org.apache.maven.- Parameters:
groupId-
-
setOptional
public void setOptional(java.lang.String optional)
Set 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.- Parameters:
optional-
-
setScope
public void setScope(java.lang.String scope)
Set 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.- Parameters:
scope-
-
setSystemPath
public void setSystemPath(java.lang.String systemPath)
Set 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}.- Parameters:
systemPath-
-
setType
public void setType(java.lang.String type)
Set 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.- Parameters:
type-
-
setVersion
public void setVersion(java.lang.String version)
Set the version of the dependency, e.g.3.2.1. In Maven 2, this can also be specified as a range of versions.- Parameters:
version-
-
isOptional
public boolean isOptional()
-
setOptional
public void setOptional(boolean optional)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
getManagementKey
public java.lang.String getManagementKey()
- Returns:
- the management key as
groupId:artifactId:type
-
clearManagementKey
public void clearManagementKey()
Clears the management key in case one field has been modified.
-
-