Ashish
Ashish

Reputation: 14707

Nested Maven Multi Module benefits over simple dependency

This question is extension of this SO questions but in my case I not only have modules but they are nested, is there any benefit of nested modules. For example if you have structure like

parent |-> child1 | - > child2 |-> child3 |-> child4 |-> child5

Would you rather have

parent |-> child1 |-> child2 |-> child3 |-> child4 |-> child5

What are the advantage and disadvantage of both approach.

Upvotes: 0

Views: 1669

Answers (1)

miskender
miskender

Reputation: 7948

Multi module project structure is good for, when you want to execute a maven command for multiple sub projects and dont have to care about order of build.(which one is dependent to other is handled automatically)For example: installing all the modules or generating javadocs for all the modules.

Parent structure is good for; inheriting dependency, plugin etc.. configuration from chain of parents. In the example you provided child5 will have dependency for every dependency it's chain of parents have defined.(in their <dependencies> tag) But as a good thing child5 wont have to specify a version for dependency which its chain of parents defined in the <dependencyManagement> tag.

If your child1-child5 is reponsible for different business logic(as a result will have very wide range of dependencies), multi module should be used.

One of the most popular maven project spring-boot have both of these concepts. I suggest you check it out https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project

Upvotes: 1

Related Questions