Maven Multi Module Project Structuring Issues

后端 未结 3 2394
無奈伤痛
無奈伤痛 2021-02-20 05:31

Well here is an interesting experience i had since last couple of weeks structuring my maven multi module project.

When i decided to use maven for my build life cycle ma

3条回答
  •  遥遥无期
    2021-02-20 06:30

    Its the way the eclipse render maven based project. It generally creates two structure. One based on master pom (parent project) and others based on individual module pom. however doing changes in any structure will reflect in the other one. As a practice I do changes in individual module folder structures and is more easy to read too.

    Personally I try to avoid multi-module projects as, if you're using the Maven Release Plugin, you are locked into releasing all your modules together.

    While this may sound like a convenience the problem arises when you need to do bug fix release to one of the modules - you end up releasing all the modules, not just the module with the bug fix, incrementing their version even though they haven't changed.

    You also take a hit if you're running CI with multi-module projects - you're build typically runs over all modules from you root pom but if you're working in a particular module, you end up taking the hit of building those that haven't changed, in effect losing some of the benefits that the modularization was meant to provide.

    So, go with independent modules but, and this is the important bit, create a common 'dependency' pom used by each.

    A 'dependency' pom is a pom that standardizes all the dependencies across your projects and is different in that those dependencies are specified in the dependencyManagement section rather than the dependencies section (it also sets up standard plugin config, etc). This allows your project poms to specify the dependency pom as their parent and then declare the dependencies they need minus the versions, which are picked up from the 'dependency' pom and thus standardized across your projects.

    If you are still concerned about being able to built everything, this can be achieved with a simple batch-file.

提交回复
热议问题