Maven artifact and groupId naming

I’m currently in the process of moving some project from Ant to Maven. Conformist as I am, I want to use well-established conventions for finding groupId and artifactId, but I can’t find any detailed conventions (there are some, but they don’t cover the points I’m wondering about).

Take this project for instance, first the Java package: com.mycompany.teatimer

tea timer is actually two words, but the Java package naming conventions forbid the insertion of underscores or hyphens, so I’m writing it all together.

I chose the groupId identical to the package ID because I think that’s a good idea. Is it?

Finally, I have to pick an artifactId, I currently went for teatimer. But when I look at other Maven projects, they use hyphens to split words in artifactIds, like this: tea-timer. But it does look weird when concatenated to the groupId: com.mycompany.teatimer.tea-timer.

How would you do this?

Another example:

Package name: com.mycompany.awesomeinhouseframework

groupId: com.mycompany.awesomeinhouseframework (?)

artifactId: awesome-inhouse-framework (?)

Maven: Unofficial artifact naming scheme?

I’m creating some Maven artifacts for various dependencies for our projects, and while I’m taking my best guess at group / artifact IDs, I’d like to add something to flag them as unofficial and crea

Maven artifact and group naming conventions

I am trying to figure out the best naming conventions for maven. For example I am creating a web service (using jersey) and lets say, for example, my domain is mydomain.com My product name is ProfitHo

Resolving Maven artifact URLs programmatically

Short: Given (groupId, artifactId, version, repository URL) can I programmatically have Maven resolve the artifact URL? Long: Given (groupId, artifactId, version, repository URL), one can download a

Maven GroupId with special characters

One best practice for choosing the Maven groupId says to choose the groupId according to the domain name of the company. Some domain names contain special characters, especially hyphen-minus. And more

i am getting “Missing artifact groupId:artifactId:version:lifecycle ” while compiling the project

I am having problems compiling my company project made in maven and I am getting Missing artifact groupId:artifactId:version:lifecycle, so I have resolved most of the build path dependencies for jars,

Artifact naming convention

We’re doing a big project on OSGi and adding some commons modules. There’s some discussion about naming the artifact. So, one possibility when naming the module is for example: cmns-definitions (for c

How to get Maven Artifact version at runtime?

I have noticed that in a Maven artifact’s JAR, the project.version attribute is included in two files: META-INF/maven/${groupId}/${artifactId}/pom.properties META-INF/maven/${groupId}/${artifactId}/po

Maven groupId for a URL with tilde

How will a Maven groupId for a URL such as site.com/~myname/projectname be formed?

Jenkins maven deploy jar to nexus – artifact naming

My java/maven project called testproject is hooked up with my jenkins and nexus repo: My pom.xml looks like: …. <distributionManagement> <!– use the following if you’re not using a snaps

What is Maven artifact?

I am trying to understand Maven a little. Can someone please explain what is an artifact and why does Maven need them?

Answers

Weirdness is highly subjective, I just suggest to follow the official recommendation:

Guide to naming conventions on groupId, artifactId and version

  • groupId will identify your project uniquely across all projects, so we need to enforce a naming schema. It has to follow the package name rules, what means that has to be at least as a domain name you control, and you can create as many subgroups as you want. Look at More information about package names.

    eg. org.apache.maven, org.apache.commons

    A good way to determine the granularity of the groupId is to use the project structure. That is, if the current project is a multiple module project, it should append a new identifier to the parent’s groupId.

    eg. org.apache.maven, org.apache.maven.plugins, org.apache.maven.reporting

  • artifactId is the name of the jar without version. If you created it then you can choose whatever name you want with lowercase letters and no strange symbols. If it’s a third party jar you have to take the name of the jar as it’s distributed.

    eg. maven, commons-math

  • version if you distribute it then you can choose any typical version with numbers and dots (1.0, 1.1, 1.0.1, …). Don’t use dates as they are usually associated with SNAPSHOT (nightly) builds. If it’s a third party artifact, you have to use their version number whatever it is, and as strange as it can look.

    eg. 2.0, 2.0.1, 1.3.1

Your convention seems to be reasonable. If I were searching for your framework in the Maven repo, I would look for awesome-inhouse-framework-x.y.jar in com.mycompany.awesomeinhouseframework group directory. And I would find it there according to your convention.

Two simple rules work for me:

  • reverse-domain-packages for groupId (since such are quite unique) with all the constrains regarding java packages names
  • project name as artifactId (keeping in mind that it should be jar-name friendly)

Consider following as for building basic first application:

groupId

  • com.companyname.project

artifactId

  • project

version

  • 0.0.1