Package adalid.jee2

Class ProjectDependency

java.lang.Object
adalid.jee2.ProjectDependency

public class ProjectDependency extends Object
Author:
Jorge Campins
  • Method Details

    • of

      public static final ProjectDependency of(String groupId, String artifactId, String version)
    • of

      public static final ProjectDependency of(ProjectDependency dependency)
    • getKey

      public String getKey()
      Returns:
      the dependency map key
    • getGroupId

      public String getGroupId()
      Returns:
      the group ID
    • getArtifactId

      public String getArtifactId()
      Returns:
      the artifact ID
    • getVersion

      public String getVersion()
      Returns:
      the version
    • getClassifier

      public String getClassifier()
      The classifier element distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number. As a motivation for this element, consider for example a project that offers an artifact targeting Java 11 but at the same time also an artifact that still supports Java 1.8. The first artifact could be equipped with the classifier jdk11 and the second one with jdk8 such that clients can choose which one to use. Another common use case for classifiers is to attach secondary artifacts to the project's main artifact. If you browse the Maven central repository, you will notice that the classifiers sources and javadoc are used to deploy the project source code and API docs along with the packaged class files.
      Returns:
      the classifier
    • setClassifier

      public ProjectDependency setClassifier(String classifier)
      Parameters:
      classifier - the classifier to set
      Returns:
      this
    • setClassifier

      public ProjectDependency setClassifier(ProjectDependencyClassifier classifier)
      Parameters:
      classifier - the classifier to set
      Returns:
      this
    • getScope

      public String getScope()
      The scope element refers to the classpath of the task at hand (compiling and runtime, testing, etc.) as well as how to limit the transitivity of a dependency. There are five scopes available:
      • compile - this is the default scope, used if none is specified. Compile dependencies are available in all classpaths. Furthermore, those dependencies are propagated to dependent projects.
      • provided - this is much like compile, but indicates you expect the JDK or a container to provide it at runtime. It is only available on the compilation and test classpath, and is not transitive.
      • runtime - this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
      • test - this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases. It is not transitive.
      • system - this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
      Returns:
      the scope
    • getValidScope

      public String getValidScope()
      The scope element refers to the classpath of the task at hand (compiling and runtime, testing, etc.) as well as how to limit the transitivity of a dependency.
      Returns:
      the scope
    • setScope

      public ProjectDependency setScope(String scope)
      Parameters:
      scope - the scope to set
      Returns:
      this
    • setScope

      public ProjectDependency setScope(ProjectDependencyScope scope)
      Parameters:
      scope - the scope to set
      Returns:
      this
    • getType

      public String getType()
      The type element corresponds to the chosen dependency type. 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 corresponds to the packaging used, though this is also not always the case. Some examples are jar, ejb-client and test-jar: see default artifact handlers for a list. New types can be defined by plugins that set extensions to true, so this is not a complete list.
      Returns:
      the type
    • getValidType

      public String getValidType()
      The type element corresponds to the chosen dependency type. 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 corresponds to the packaging used, though this is also not always the case. Some examples are jar, ejb-client and test-jar: see default artifact handlers for a list. New types can be defined by plugins that set extensions to true, so this is not a complete list.
      Returns:
      the type
    • setType

      public ProjectDependency setType(String type)
      Parameters:
      type - the type to set
      Returns:
      this
    • setType

      Parameters:
      type - the type to set
      Returns:
      this
    • isOptional

      public boolean isOptional()
      The optional element marks a dependency optional when this project itself is a dependency. For example, imagine a project A that depends upon project B to compile a portion of code that may not be used at runtime, then we may have no need for project B for all project. So if project X adds project A as its own dependency, then Maven does not need to install project B at all. In the shortest terms, optional lets other projects know that, when you use this project, you do not require this dependency in order to work correctly.
      Returns:
      the optional indicator
    • setOptional

      public ProjectDependency setOptional(boolean optional)
      Parameters:
      optional - the optional indicator to set
      Returns:
      this
    • isValid

      public boolean isValid()
      Returns:
      the validity indicator
    • merge

      public ProjectDependency merge(ProjectDependency dependency)
      Parameters:
      dependency - the dependency to merge
      Returns:
      this
    • mergeOptional

      public ProjectDependency mergeOptional(boolean optional)
      Sets the optional indicator if and only if both the parameter and the current value are true
      Parameters:
      optional - the optional indicator to set
      Returns:
      this
    • toString

      public String toString()
      Overrides:
      toString in class Object