org.apache.maven.model
Class Dependency

java.lang.Object
  extended by org.apache.maven.model.Dependency
All Implemented Interfaces:
Serializable, Cloneable, InputLocationTracker

public class Dependency
extends Object
implements Serializable, Cloneable, InputLocationTracker

The <dependency> element contains information about a dependency of the project.

Version:
$Revision$ $Date$
See Also:
Serialized Form

Constructor Summary
Dependency()
           
 
Method Summary
 void addExclusion(Exclusion exclusion)
          Method addExclusion.
 Dependency clone()
          Method clone.
 String getArtifactId()
          Get the unique id for an artifact produced by the project group, e.g.
 String getClassifier()
          Get the classifier of the dependency.
 List<Exclusion> getExclusions()
          Method getExclusions.
 String getGroupId()
          Get the project group that produced the dependency, e.g.
 InputLocation getLocation(Object key)
          Gets the location of the specified field in the input source.
 String getManagementKey()
           
 String getOptional()
          Get indicates the dependency is optional for use of this library.
 String getScope()
          Get the scope of the dependency - compile, runtime, test, system, and provided.
 String getSystemPath()
          Get fOR SYSTEM SCOPE ONLY.
 String getType()
          Get the type of dependency.
 String getVersion()
          Get the version of the dependency, e.g.
 boolean isOptional()
           
 void removeExclusion(Exclusion exclusion)
          Method removeExclusion.
 void setArtifactId(String artifactId)
          Set the unique id for an artifact produced by the project group, e.g.
 void setClassifier(String classifier)
          Set the classifier of the dependency.
 void setExclusions(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.
 void setGroupId(String groupId)
          Set the project group that produced the dependency, e.g.
 void setLocation(Object key, InputLocation location)
          Sets the location of the specified field.
 void setOptional(boolean optional)
           
 void setOptional(String optional)
          Set indicates the dependency is optional for use of this library.
 void setScope(String scope)
          Set the scope of the dependency - compile, runtime, test, system, and provided.
 void setSystemPath(String systemPath)
          Set fOR SYSTEM SCOPE ONLY.
 void setType(String type)
          Set the type of dependency.
 void setVersion(String version)
          Set the version of the dependency, e.g.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dependency

public Dependency()
Method Detail

addExclusion

public void addExclusion(Exclusion exclusion)
Method addExclusion.

Parameters:
exclusion -

clone

public Dependency clone()
Method clone.

Overrides:
clone in class Object
Returns:
Dependency

getArtifactId

public String getArtifactId()
Get the unique id for an artifact produced by the project group, e.g. maven-artifact.

Returns:
String

getClassifier

public String getClassifier()
Get the classifier of the dependency. This allows distinguishing two artifacts that belong to the same POM but were built differently, and is appended to the filename after the version. For example, jdk14 and jdk15.

Returns:
String

getExclusions

public List<Exclusion> getExclusions()
Method getExclusions.

Returns:
List

getGroupId

public String getGroupId()
Get the project group that produced the dependency, e.g. org.apache.maven.

Returns:
String

getLocation

public InputLocation getLocation(Object key)
Description copied from interface: InputLocationTracker
Gets the location of the specified field in the input source.

Specified by:
getLocation in interface InputLocationTracker
Parameters:
key -
Returns:
InputLocation

getOptional

public 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 is String for technical reasons, the semantic type is actually Boolean. Default value is false.

Returns:
String

getScope

public String getScope()
Get the scope of the dependency - compile, runtime, test, system, and provided. 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.

Returns:
String

getSystemPath

public 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 String getType()
Get the type of dependency. This defaults to jar. While it usually represents the extension on the filename of the dependency, that is not always the case. A type can be mapped to a different extension and a classifier. The type often correspongs to the packaging used, though this is also not always the case. Some examples are jar, war, ejb-client and test-jar. New types can be defined by plugins that set extensions to true, so this is not a complete list.

Returns:
String

getVersion

public 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(String artifactId)
Set the unique id for an artifact produced by the project group, e.g. maven-artifact.

Parameters:
artifactId -

setClassifier

public void setClassifier(String classifier)
Set the classifier of the dependency. This allows distinguishing two artifacts that belong to the same POM but were built differently, and is appended to the filename after the version. For example, jdk14 and jdk15.

Parameters:
classifier -

setExclusions

public void setExclusions(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(String groupId)
Set the project group that produced the dependency, e.g. org.apache.maven.

Parameters:
groupId -

setLocation

public void setLocation(Object key,
                        InputLocation location)
Description copied from interface: InputLocationTracker
Sets the location of the specified field.

Specified by:
setLocation in interface InputLocationTracker
Parameters:
key -
location -

setOptional

public void setOptional(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 is String for technical reasons, the semantic type is actually Boolean. Default value is false.

Parameters:
optional -

setScope

public void setScope(String scope)
Set the scope of the dependency - compile, runtime, test, system, and provided. 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.

Parameters:
scope -

setSystemPath

public void setSystemPath(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(String type)
Set the type of dependency. This defaults to jar. While it usually represents the extension on the filename of the dependency, that is not always the case. A type can be mapped to a different extension and a classifier. The type often correspongs to the packaging used, though this is also not always the case. Some examples are jar, war, ejb-client and test-jar. New types can be defined by plugins that set extensions to true, so this is not a complete list.

Parameters:
type -

setVersion

public void setVersion(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 String toString()
Overrides:
toString in class Object
See Also:
Object.toString()

getManagementKey

public String getManagementKey()
Returns:
the management key as groupId:artifactId:type


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.