2

I am trying to figure out the best naming conventions for Maven. For example I am creating a web service (using Jersey) and let's say, for example, my domain is mydomain.com

My product name is ProfitHorse. So would it be best practice to put the groupid with my reverse dns name and adding the ProfitHorse on it like so

com.mydomain.profithorse

and the artifact would be the actually name of the module in this case its a Jersey REST service so something like

rest-service

If I have further modules that I can use the same groupId but just change the artifact i.e.

email-server

Is it good practice to use -(dash) between words? I presume it's not case sensitive so using camel casing or Pascal casing wouldn't really work.

I am little confused with regards to conventions.

halfer
  • 19,824
  • 17
  • 99
  • 186
Martin
  • 23,844
  • 55
  • 201
  • 327
  • 1
    About case-sensitiveness : I currently have issues with a projet where 2 modules have the same artifactIds but with different cases. On Linux the project builds like a charm On Windows, Maven confuses the 2 modules and fails to build the project So case-sensitiveness seems platform specific – lolo101 May 07 '19 at 12:23

1 Answers1

15

In this case I would recommend:

groupId: reverse domain name + project name, separated by dots, everything lower case: com.mydomain.profithorse

artifactId: project name + components, separated by dashes, everything lower case: profithorse-server-service or profithorse-server-service-rest or profithorse-server-rest

For the artifactId consider:

  • the artifactId will define the jar name. That's why I recommend to add the project name as well, else you end up with a rest-service-<version>.jar - not very descriptive
  • use as many components parts to make it easy to see what it provides.
    • do you have a server and a client module?
    • do you have several kinds of services? or just rest?
    • would a vertical layering per feature make sense? Then also add the feature name to the artifactId

I guess the Maven coordinates are case sensitive, but I'm not sure. I suggest to always use lower case names.

Puce
  • 37,247
  • 13
  • 80
  • 152
  • 1
    Thanks for the that. Good explanation, although it appears there was another question that answered mine it didn't go into good details or answer my specifics... you did.. thank you – Martin Apr 20 '14 at 19:13