Interface DependencyFactory
-
- All Known Subinterfaces:
BuildFactory
,PluginFactory
- All Known Implementing Classes:
ModelFactory
,ModelTest
,ModelTest2
public interface DependencyFactory
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
DependencyFactory.DependencyExclusions
-
Method Summary
All Methods Instance Methods Default Methods Modifier and Type Method Description default org.apache.maven.model.Dependency
compile(java.lang.String definition)
default org.apache.maven.model.Dependency
dependency(java.lang.String definition)
default org.apache.maven.model.Dependency
dependency(java.lang.String definition, java.lang.String scope)
default org.apache.maven.model.Dependency
dependency(NamedValue... keyValuePairs)
Factory method to create dependency.default org.apache.maven.model.Exclusion
exclusion(NamedValue... keyValuePairs)
default NamedValue
exclusions(org.apache.maven.model.Exclusion... exclusions)
default org.apache.maven.model.Dependency
provided(java.lang.String definition)
default org.apache.maven.model.Repository
repository(java.lang.String id, java.lang.String name, java.lang.String url)
default org.apache.maven.model.Repository
repository(java.lang.String id, java.lang.String name, java.lang.String url, java.lang.String layout, org.apache.maven.model.RepositoryPolicy releases, org.apache.maven.model.RepositoryPolicy snapshots)
default org.apache.maven.model.Repository
repository(NamedValue... keyValuePairs)
Factory method to create repository.default org.apache.maven.model.RepositoryPolicy
repositoryPolicy(boolean enabled, java.lang.String updatePolicy, java.lang.String checksumPolicy)
default org.apache.maven.model.Dependency
runtime(java.lang.String definition)
default org.apache.maven.model.Dependency
test(java.lang.String definition)
-
-
-
Method Detail
-
dependency
default org.apache.maven.model.Dependency dependency(NamedValue... keyValuePairs)
Factory method to create dependency.
Each key-value pair is a construct
key -> "value"
Where 'key' is the name of the property to set and "value" is it's string value.
All possible keys are:
- groupId - The project group that produced the dependency, e.g.
org.apache.maven
. - artifactId - The unique id for an artifact produced by the project group, e.g.
maven-artifact
. - version - The version of the dependency, e.g.
3.2.1
. - type - The type of dependency. 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
,war
,ejb-client
andtest-jar
: see default artifact handlers for a list. New types can be defined by plugins that setextensions
totrue
, so this is not a complete list. Default value is "jar" - classifier - The classifier of the dependency. It is appended
to
the filename after the version. This allows:
- referring to attached artifact, for example
sources
andjavadoc
: see default artifact handlers for a list, - distinguishing two artifacts
that belong to the same POM but were built
differently.
For example,
jdk14
andjdk15
.
- referring to attached artifact, for example
- scope - The scope of the dependency -
compile
,runtime
,test
,system
, andprovided
. 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 iscompile
. - systemPath - 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}
. - optional - 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 actuallyBoolean
. Default value isfalse
. - exclusions - see exmplanation below
In addition to key-value pairs described above you can also you special method to define exclusions:
- exclusions - List of dependency exclusions. Each individual exclusion can have two properties - groupId and artifactId(optional since you can exclude entire group).
exclusions( exclusion(groupId -> "grpToExclude", artifactId -> "artifactToExclue"), exclusion(groupId -> "otherGrpToExclude", artifactId -> "otherArtifactToExclue") )
- Parameters:
keyValuePairs
- - array of key -> "value" pairs. Example:dependency(groupId -> "junit", artifactId -> "junit", version -> "3.8.1", scope -> "test")
- Returns:
- defined Dependency
- groupId - The project group that produced the dependency, e.g.
-
dependency
default org.apache.maven.model.Dependency dependency(java.lang.String definition)
-
compile
default org.apache.maven.model.Dependency compile(java.lang.String definition)
-
provided
default org.apache.maven.model.Dependency provided(java.lang.String definition)
-
runtime
default org.apache.maven.model.Dependency runtime(java.lang.String definition)
-
test
default org.apache.maven.model.Dependency test(java.lang.String definition)
-
dependency
default org.apache.maven.model.Dependency dependency(java.lang.String definition, java.lang.String scope)
-
repository
default org.apache.maven.model.Repository repository(java.lang.String id, java.lang.String name, java.lang.String url)
-
repository
default org.apache.maven.model.Repository repository(NamedValue... keyValuePairs)
Factory method to create repository. Used for both - "repositories" and "pluginRepositories"
Each key-value pair is a construct
key -> "value"
Where 'key' is the name of the property to set and "value" is it's string value.
All possible keys are:
- id - A unique identifier for a repository. This is used to match the repository to configuration in the
settings.xml
file, for example. Furthermore, the identifier is used during POM inheritance and profile injection to detect repositories that should be merged. - name - Human readable name of the repository.
- url - The url of the repository, in the form
protocol://hostname/path
- layout - The type of layout this repository uses for locating and storing artifacts - can be
legacy
ordefault
- Parameters:
keyValuePairs
- - array of key -> "value" pairs. Example:repository(id -> "my-repo", url -> "http://myserver/repo")
- Returns:
- defined Repository
- id - A unique identifier for a repository. This is used to match the repository to configuration in the
-
repository
default org.apache.maven.model.Repository repository(java.lang.String id, java.lang.String name, java.lang.String url, java.lang.String layout, org.apache.maven.model.RepositoryPolicy releases, org.apache.maven.model.RepositoryPolicy snapshots)
-
repositoryPolicy
default org.apache.maven.model.RepositoryPolicy repositoryPolicy(boolean enabled, java.lang.String updatePolicy, java.lang.String checksumPolicy)
-
exclusions
default NamedValue exclusions(org.apache.maven.model.Exclusion... exclusions)
-
exclusion
default org.apache.maven.model.Exclusion exclusion(NamedValue... keyValuePairs)
-
-