Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven parent-child relationship

Tags:

java

maven

I have encountered the below "pattern" for maven parent-child relationships: Relation ship examplehttp://yuml.me/3f8dd366

In this example we have a module with 2 sub modules. The module has a parent pom "Parent for building the Module" which knows the two sub-modules as it's children.

The sub-modules how ever have no idea that this parent knows them, and they think their parent is the one named "Parent for dependency management". Which has common configurations like dependency management, plugin configuration, common properties etc.

My question:
Is this a "good" pattern? Meaning does it have advantages/disadvantages as the seemingly more intuitive patter of child<->parent relationship

like image 928
RonK Avatar asked Mar 20 '13 10:03

RonK


1 Answers

One interesting thing to look at is the aggregator pom.

It's a pom that groups project by module, without having a "parent-child" relationship. The aggregator pom doesn't have dependencies management. It only manages the build.

Having both parent(s) pom and aggregator pom is quite a powerful feature of maven.

You can find more information here.

This maven page also has valuable insight on how to set up pom for complex projects.

like image 117
phoenix7360 Avatar answered Oct 22 '22 08:10

phoenix7360