Marcio Barroso
Marcio Barroso

Reputation: 783

Best structure for multi-modules maven project

I would like to know if there is a best way to group maven projects.

If I have more than 1 pom project, how is the best way to set them?

Solution 1:
groupid:parent:version (pom)
    groupid.parent:child:version (jar)
    groupid.parent:subproject:version (pom)
        groupid.parent.subproject:childOne:version (jar)
        groupid.parent.subproject:childTwo:version (jar)
        groupid.parent.subproject:childThree:version (jar)

Solution 2:
groupid:parent:version (pom)
    groupid:parent-child:version (jar)
    groupid:parent-subproject:version (pom)
        groupid:parent-subproject-childOne:version (jar)
        groupid:parent-subproject-childTwo:version (jar)
        groupid:parent-subproject-childThree:version (jar)

Any other options?!?

Upvotes: 1

Views: 176

Answers (1)

Dan
Dan

Reputation: 1995

I'm preferential to the module organization described in Solution 1. Notice with this approach that you could encounter (or anticipate) some naming collisions...which are politely mitigated by most Maven plugins. For example:

  • You have a global library in your Maven ecosystem named some.groupId:service:1.0.0
  • And then inside one of your Maven multi-module projects, an artefact named another.groupId:service:1.0.0

Now pretend you have a Maven web application module that depends on both of the afore mentioned service artefacts. When the maven-war-plugin copies the dependencies to the WEB-INF/lib directory, it is smart enough to discover the service jar filename collisions and renames each jar to include their groupId.

I know that was a lot of extra information, but some people are not aware of this bit of Maven war intelligence...

Upvotes: 1

Related Questions