I am confused about the difference between the artifactItem
defined in maven-dependency-plugin
and the dependency
defined in dependencyManagement
/dependencies
in maven.
My real question is why do you put artifactItem
in maven-dependency-plugin
-> configuration
->artifactItems
while you can put the dependency
under dependencyManagement
/dependencies
?
Is it because that you can specify copy/pack the dependency to a specified folder using maven-dependency-plugin? If so, does it means that maven-dependency-plugin is a superset of dependencyManagement? If true, why bother to have dependencyManagement?
To make it simple, let’s not consider multiple projects. Let’s assume that there is only one project and one pom, it doesn’t have any child project.
Advertisement
Answer
The artifactItem
of the maven-dependency-plugin
only applies to that specific step (e.g. unpacking that dependency or copying it somewhere). In dependencyManagement
you can specify artifact versions etc., so that you can include them in submodules just by group and artifact id in the dependencies
section, while the version is only configured in the dependencyManagement
block. So technically, those 3 configuration ways (maven-dependencies-plugin
, dependencyManagement
and dependencies
all serve their own purposes, neither is a superset or subset of another one.