Starting from Maven 2.0.9 there is possibility to include
<type>pom</type>
<scope>import</scope>
in the <dependencyManagement>
section.
As I understand it, it will be "replaced" with dependencies included in this pom as if they were originally defined here.
What is the difference between solution above and simple dependency to this pom without import
scope (I saw the latter being called "dependencies grouping")? Is the only difference that such "grouped" dependencies have lower priority while resolving dependencies precedence?
Best Answer
You can only import managed dependencies. This means you can only import other POMs into the
dependencyManagement
section of your project's POM. i.e.What then happens is that all the dependencies defined in the
dependencyManagement
section of theother-pom-artifact-id
are included in your POM'sdependencyManagement
section. You can then reference these dependencies in thedependency
section of your POM (and all of its child POMs) without having to include aversion
etc.However if in your POM you simply define a normal dependency to
other-pom-artifact-id
then alldependencies
from thedependency
section of theother-pom-artifact-id
are included transitively in your project - however the dependencies defined in thedependencyManagement
section of theother-pom-artifact-id
are not included at all.So basically the two different mechanisms are used for importing/including the two different types of dependencies (managed dependencies and normal dependencies).
There is a good page on the maven website, which can explain this far better than I can, Dependency Management in Maven and it also contains specific information on importing dependencies.