Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming convention for Maven Artifacts

Tags:

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

like image 351
Manoj Avatar asked Jun 30 '10 14:06

Manoj


1 Answers

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.

<groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId>  <groupId>org.codehaus.mojo</groupId> <artifactId>jboss-maven-plugin</artifactId>  <groupId>net.sf.barcode4j</groupId> <artifactId>barcode4j-fop-ext-0.20.5-complete</artifactId>  <groupId>org.springframework</groupId> <artifactId>spring</artifactId>  <groupId>opensymphony</groupId> <artifactId>oscache</artifactId>  <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-libs</artifactId>  <groupId>javax.resource</groupId> <artifactId>connector-api</artifactId>  <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId>  <groupId>javax.transaction</groupId> <artifactId>jta</artifactId> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> 

And then there are many where the group and artifact IDs are the same unqualified name, e.g.:

<groupId>log4j</groupId> <artifactId>log4j</artifactId>  <groupId>velocity</groupId> <artifactId>velocity</artifactId>  <groupId>fop</groupId> <artifactId>fop</artifactId>  <groupId>commons-lang</groupId> <artifactId>commons-lang</artifactId> 

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).

like image 171
Péter Török Avatar answered Oct 06 '22 06:10

Péter Török