Maven multi-project stucture can get quite difficult to manage once you have a relatively deep hierarchy and more than a few projects. Looking at one such complex structure I found that much of this complexity can be avoided by carefully looking at the relation between parent and child projects and understanding why the projects have been split in the first place.
Maven allows composition and association type relationships between parent and children POMs (projects). The composition relation is expressed by including the child in the modules element of the parent POM and refering to the parent from the child POM. The association type relation is expressed by only refering to the parent from the child POM.
This all seams fairly straight forward until you start thinking about your release strategy. In a composition relationship all child modules must be released with the parent so that if you want to release changes in a child module then ideally you should release it as part of a full release of it's parent. Notice I say "must" even though maven allows you to release the children individually. Well, if you can think of scenarios where the child may be released independently of the parent then surely a composition type relationship is not appropriate?
Another guideline I find useful is to maintain exactly the same versions for all projects in a composition relationship since they must be released together. Assosiation type releasions ships should always refer to a released version of it's parent.
Lastly project hierarchies are not the only way to share common POM setups and dependencies. The other option is to use maven profiles. Typically you'd have a combination of a hierarchical project simplified by use of maven profiles.
Mash is a pragmatic software craftsman always looking to improve his software creation skills and helping others do the same. He firmly believes that a well-rounded software craftsman must have a keen interest in all aspects of software creation, including; process, people, technology, user experience, development, operation, maintenance, and social impact. He relishes the daily challenges that Codurance brings to him–stretching his existing knowledge and expertise allowing him to constantly grow as a professional.
Mash is an advisor and a leader. During his diverse career, he has succeeded in invigorating large ailing software projects as well as creating highly effective software teams and departments. His broad and deep technical knowledge, organisational skills, craft focus, and empathy to people involved have been integral to his success. He has worked in many roles for charities, investment banks, consultancies, government, media and cloud providers. He prides himself at being a hands-on software developer and believes that software development skills are very hard to learn and the best way to maintain them is to apply them.All author posts
Software es nuestra pasión.
Somos Software Craftspeople. Construimos software bien elaborado para nuestros clientes, ayudamos a los desarrolladores a mejorar en su oficio a través de la formación, la orientación y la tutoría y ayudamos a las empresas a mejorar en la distribución de software.