I would say that it is a matter of your own taste and preference.
Usually you should group similar sets of modules under the same groupId . For example, you might have the following:
com.foo.bar:parent (parent pom for all projects) com.foo.bar:core-api (some very core classes) com.foo.bar:commons (some common classes) com.foo.bar:io (some IO classes) com.foo.bar:utils (some utility classes) com.foo.bar.messaging:messaging-core (messaging core classes) com.foo.bar.messaging:messaging-rest-api (REST API for messaging) com.foo.bar.messaging:messaging-jms (some JMS code) com.foo.bar.web:rest-api (your restlets) com.foo.bar.web:web-core (core classes to be used by web modules) com.foo.bar.web:web-parent (a parent pom for all your web projects) com.foo.bar.web:web-ui (UI stuff like css/images/js/etc) com.foo.bar.web:web-assembly (a web assembly that bundles all modules) ... (I hope by now you get my drift) ...
You do not need to group all modules whose classes begin with a common package under the same groupId . You could do it if you want, but it's rare how people really use it in real life. The level of rigor and detail is up to you, but in the case of artifacts this usually does not matter much since there is nothing to associate the package name with groupId .
In addition, using a prefix for your modules is also useful, but up to you. If you want, you can:
com.foo.bar:bar-parent com.foo.bar:bar-core-api com.foo.bar:bar-commons
It really is up to you. Some argue that if you have groupId as com.foo.bar , you do not need to have the bar- prefix in bar-parent . To some extent this is true. But then you could have com.foo.bar:parent and com.foo.bar.web:parent , and when you use a storage manager like Nexus, Archiva or Artifactory, and you are looking for parent (or some other common name, for example ... commons , for example), you can get a rather long list of results, rather than bar-parent .
In the end, what matters is at what level of detail are you ready to go and what really suits your needs. Maven allows you all the freedom you need in this regard.
source share