We are currently trying to mavenize the existing projects in our company. We have executed a POC and are currently documenting our learnings and guidelines. I have come up the following naming convention for the maven artifacts. Please share your comments on the same
Note: In our company, projectname is always unique
For a single level multi module maven project
Parent (pom)
- groupId : org.companyname.projectname
- artifactId : org.companyname.projectname
- version : x.x.x
eg : org.companyname.projectname:org.companyname.projectname-1.0.0.pom
Modules (jar)
- groupId : org.companyname.projectname
- artifactId : org.companyname.projectname.modulename
- version : x.x.x
eg: org.companyname.projectname:org.companyname.projectname.modulename-1.0.0.jar
For a multi level multi module maven project
Parent (pom)
- groupId : org.companyname.projectname
- artifactId : org.companyname.projectname
- version : x.x.x
eg : org.companyname.projectname:org.companyname.projectname-1.0.0.pom
SubParent (pom)
- groupId : org.companyname.projectname
- artifactId : org.companyname.projectname.subcategory
- version : x.x.x
eg : org.companyname.projectname:org.companyname.projectname.subcategory-1.0.0.pom
Module (jar)
- groupId : org.companyname.projectname
- artifactId : org.companyname.projectname.subcategory.modulename
- version : x.x.x
eg : org.companyname.projectname:org.companyname.projectname.subcategory.modulename-1.0.0.jar
Using an unqualified name for the groupId matching the artifactId (e.g.
log4j
) is an old deprecated practice which is not recommended: it's bad at the file system level, it generates "repository mess", it makes artifacts harder to find when browsing a repository (even if most people use a search engine nowadays).The recommendation is to include your domain name in the groupId and I would certainly not repeat it in the artifactId (to my knowledge, Spring is NOT doing that - except maybe for OSGI artifacts?).
Here is what I use:
Parent (pom)
eg : org.companyname.projectname:root-1.0.0.pom
SubParent (pom)
eg : org.companyname.projectname:subcategory-parent-1.0.0.pom
Module (jar)
eg : org.companyname.projectname:modulename-1.0.0.jar
And I also use conventions for the
<description>
element to have a clean overview during reactor builds. Here is an example on a pet project:This is heavily inspired by Vincent Massol's way to organize big builds like he did with XWiki or Cargo.
IMO you need not include
org.companyname
in the artifactId - it is just duplicating the information already present in the groupId, thus making the artifact names longer and less readable.Update: FYI, looking through the dependencies of our project, I see plenty of similar examples, e.g.
And then there are many where the group and artifact IDs are the same unqualified name, e.g.:
But I haven't seen any having a fully qualified group ID and an identical artifact ID (which e.g. for Log4J would be
org.apache.log4j:org.apache.log4j
).