0

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.

Ashish
  • 14,295
  • 21
  • 82
  • 127
  • The nested structure makes only sense if you have modules which have an appropriate architecture..otherwise it does not make sense...For example this one has two level structure https://github.com/khmarbaise/supose which makes sense base on the architecture...I would never flatten that – khmarbaise Mar 01 '18 at 17:55
  • @khmarbaise - thank, I would never flatten out 2 levels but 5 level nesting is just too much I think – Ashish Mar 01 '18 at 18:58
  • That depends on the project and it's architecture but I would reconsider this number of levels.. – khmarbaise Mar 02 '18 at 07:22

1 Answers1

1

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

miskender
  • 7,460
  • 1
  • 19
  • 23