Class Dependency

java.lang.Object
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:
  • Constructor Details Link icon

    • Dependency Link icon

      public Dependency()
  • Method Details Link icon

    • addExclusion Link icon

      public void addExclusion(Exclusion exclusion)
      Method addExclusion.
      Parameters:
      exclusion - a exclusion object.
    • clone Link icon

      public Dependency clone()
      Method clone.
      Overrides:
      clone in class Object
      Returns:
      Dependency
    • getArtifactId Link icon

      public String getArtifactId()
      Get the unique id for an artifact produced by the project group, e.g. maven-artifact.
      Returns:
      String
    • getClassifier Link icon

      public 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 sources and javadoc: see default artifact handlers for a list,
      • distinguishing two artifacts that belong to the same POM but were built differently. For example, jdk14 and jdk15.
      Returns:
      String
    • getExclusions Link icon

      public List<Exclusion> getExclusions()
      Method getExclusions.
      Returns:
      List
    • getGroupId Link icon

      public String getGroupId()
      Get the project group that produced the dependency, e.g. org.apache.maven.
      Returns:
      String
    • getLocation Link icon

      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 - a key object.
      Returns:
      InputLocation
    • getOptional Link icon

      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
    • setLocation Link icon

      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 - a key object.
      location - a location object.
    • setOtherLocation Link icon

      public void setOtherLocation(Object key, InputLocation location)
      Parameters:
      key - a key object.
      location - a location object.
    • getScope Link icon

      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. The default scope is compile.
      Returns:
      String
    • getSystemPath Link icon

      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 Link icon

      public 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 are jar, war, ejb-client and test-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 Link icon

      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 Link icon

      public void removeExclusion(Exclusion exclusion)
      Method removeExclusion.
      Parameters:
      exclusion - a exclusion object.
    • setArtifactId Link icon

      public void setArtifactId(String artifactId)
      Set the unique id for an artifact produced by the project group, e.g. maven-artifact.
      Parameters:
      artifactId - a artifactId object.
    • setClassifier Link icon

      public void setClassifier(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 sources and javadoc: see default artifact handlers for a list,
      • distinguishing two artifacts that belong to the same POM but were built differently. For example, jdk14 and jdk15.
      Parameters:
      classifier - a classifier object.
    • setExclusions Link icon

      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 - a exclusions object.
    • setGroupId Link icon

      public void setGroupId(String groupId)
      Set the project group that produced the dependency, e.g. org.apache.maven.
      Parameters:
      groupId - a groupId object.
    • setOptional Link icon

      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 - a optional object.
    • setScope Link icon

      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. The default scope is compile.
      Parameters:
      scope - a scope object.
    • setSystemPath Link icon

      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 - a systemPath object.
    • setType Link icon

      public void setType(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 are jar, war, ejb-client and test-jar: see default artifact handlers for a list. New types can be defined by extensions, so this is not a complete list.
      Parameters:
      type - a type object.
    • setVersion Link icon

      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 - a version object.
    • isOptional Link icon

      public boolean isOptional()
    • setOptional Link icon

      public void setOptional(boolean optional)
    • toString Link icon

      public String toString()
      Overrides:
      toString in class Object
      See Also:
    • getManagementKey Link icon

      public String getManagementKey()
      Returns:
      the management key as groupId:artifactId:type
    • clearManagementKey Link icon

      public void clearManagementKey()
      Clears the management key in case one field has been modified.