Dependency Management and Maven
Achieving dependency management with Maven for multiple projects.
Join the DZone community and get the full member experience.Join For Free
Maven is a great and mature build automation tool. There is always a solution on almost everything. The main case you might stumble on organization projects is dependency management. Instead of each project having its own dependencies you want a centralized way to inherit those dependencies.
In those cases, you declare on the parent prom the managed dependencies. In my example, I just want to include the Akka stream dependencies.
What I use is the dependency management block.
Now the child project would be able to include those libraries without specifying the version. Having the version derived and managed is essential. Many unpleasant surprises can come if a version is incompatible.
Now on to the child module the versions are declared without the version since it is the child module.
On another note sometimes we want to use another project’s dependency management without that project being our parent. Those are cases where you need to include the dependency management from a parent project when you already have a parent project.
As you can see in the block
We just included the dependency management from another project, which can be applied to inherit dependencies from multiple projects.
We just achieved managing the dependencies for multiple projects using either a parent project or just another project.
Published at DZone with permission of Emmanouil Gkatziouras, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.