I have a multi module Maven project and I want the sub projects to inherit the versions for third party dependencies which I have specified in the parent project. This is so I don't need to replicate version numbers everywhere. It's not working though and when I leave out the version number on the children I get the error:
dependencies.dependency.version is missing
What do I need to change to get this working?
Right-click the utility project, and select Maven>Add Dependency. Type a dependency name in the Enter groupID… field (e.g., commons-logging) to search for a dependency. Select the dependency, and click OK.
There is a difference between inheriting from a parent project and being managed by a multimodule project. A parent project is one that passes its values to its children. A multimodule project simply manages a group of other subprojects or modules.
2. Maven's Multi-Module Project. A multi-module project is built from an aggregator POM that manages a group of submodules. In most cases, the aggregator is located in the project's root directory and must have packaging of type pom.
Backward Compatibility − You can easily port the multiple modules of a project into Maven 3 from older versions of Maven. It can support the older versions also. Automatic parent versioning − No need to specify the parent in the sub module for maintenance.
The <dependencyManagement>
section of the parent POM is meant for this purpose:
dependencyManagement
: is used by POMs to help manage dependency information across all of its children. If themy-parent
project usesdependencyManagement
to define a dependency onjunit:junit:4.0
, then POMs inheriting from this one can set their dependency giving thegroupId=junit
andartifactId=junit
only, then Maven will fill in theversion
set by the parent. The benefits of this method are obvious. Dependency details can be set in one central location, which will propagate to all inheriting POMs. In addition, the version and scope of artifacts which are incorporated from transitive dependencies may also be controlled by specifying them in a dependency management section.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With