Class DependencyEntry

java.lang.Object
org.apache.maven.plugins.dependency.pom.DependencyEntry

public class DependencyEntry extends Object
Represents parsed Maven dependency coordinates (GAV + scope/type/classifier). Supports parsing from a colon-separated string in the format: groupId:artifactId[:version] or groupId:artifactId[:extension[:classifier]]:version.

This follows the standard Maven coordinate convention used by org.eclipse.aether.artifact.DefaultArtifact. Scope and optional are not part of coordinates and must be specified as separate parameters.

Design note: This class exists because no single class on the classpath covers all requirements. DefaultArtifact (Aether) provides GAV parsing but requires a version (throws on g:a) and lacks scope/optional. Dependency (maven-model) has all fields but no coordinate string parser. This class bridges both: it parses g:a (needed by dependency:remove) and carries scope/optional.

Since:
3.11.0
  • Constructor Details

    • DependencyEntry

      public DependencyEntry()
    • DependencyEntry

      public DependencyEntry(String groupId, String artifactId)
  • Method Details

    • parse

      public static DependencyEntry parse(String gav)
      Parses a colon-separated coordinate string following Maven conventions.

      Supported formats:

      • groupId:artifactId — minimum
      • groupId:artifactId:version
      • groupId:artifactId:extension:version
      • groupId:artifactId:extension:classifier:version
      Parameters:
      gav - the coordinate string
      Returns:
      the parsed coordinates
      Throws:
      IllegalArgumentException - if the string has fewer than 2 or more than 5 segments
    • validate

      public void validate()
      Validates that required fields are present.
      Throws:
      IllegalArgumentException - if groupId or artifactId is missing
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getGroupId

      public String getGroupId()
    • setGroupId

      public void setGroupId(String groupId)
    • getArtifactId

      public String getArtifactId()
    • setArtifactId

      public void setArtifactId(String artifactId)
    • getVersion

      public String getVersion()
    • setVersion

      public void setVersion(String version)
    • getScope

      public String getScope()
    • setScope

      public void setScope(String scope)
    • getType

      public String getType()
    • setType

      public void setType(String type)
    • getClassifier

      public String getClassifier()
    • setClassifier

      public void setClassifier(String classifier)
    • getOptional

      public Boolean getOptional()
    • setOptional

      public void setOptional(Boolean optional)