Package adalid.jee2
Class ProjectDependency
java.lang.Object
adalid.jee2.ProjectDependency
- Author:
- Jorge Campins
-
Method Summary
Modifier and TypeMethodDescriptionThe classifier element distinguishes artifacts that were built from the same POM but differ in content.getKey()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.getType()The type element corresponds to the chosen dependency type.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.The type element corresponds to the chosen dependency type.booleanThe optional element marks a dependency optional when this project itself is a dependency.booleanisValid()merge(ProjectDependency dependency) mergeOptional(boolean optional) Sets the optional indicator if and only if both the parameter and the current value are truestatic final ProjectDependencyof(ProjectDependency dependency) static final ProjectDependencysetClassifier(ProjectDependencyClassifier classifier) setClassifier(String classifier) setOptional(boolean optional) setScope(ProjectDependencyScope scope) setType(ProjectDependencyType type) toString()
-
Method Details
-
of
-
of
-
getKey
- Returns:
- the dependency map key
-
getGroupId
- Returns:
- the group ID
-
getArtifactId
- Returns:
- the artifact ID
-
getVersion
- Returns:
- the version
-
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
- Parameters:
classifier- the classifier to set- Returns:
- this
-
setClassifier
- Parameters:
classifier- the classifier to set- Returns:
- this
-
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
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
- Parameters:
scope- the scope to set- Returns:
- this
-
setScope
- Parameters:
scope- the scope to set- Returns:
- this
-
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
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
- 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
- Parameters:
optional- the optional indicator to set- Returns:
- this
-
isValid
public boolean isValid()- Returns:
- the validity indicator
-
merge
- Parameters:
dependency- the dependency to merge- Returns:
- this
-
mergeOptional
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
-