Search code examples
maven-2namingconvention

What are Best Practices for Maven Modules Naming?


Assuming that we have a project named project and modules module1 and module2, earlier I tend to use the following naming strategy:

-- project
  -- projectModule1
  -- projectModule2

Now I use another:

-- project
  -- project-module1
  -- project-module2

What are best practices for Maven modules naming?


Solution

  • I wrote some notes on this in the "Effective Implementation" book, but there is no rule or canonical convention.

    To summarise some:

    First of all, the most important things is that you are consistent.

    General Maven convention uses '-' as the separator (commons-lang, maven-model).

    If you intend for it to be used externally, remember the module = artifact ID = filename (in best practice), so it needs to be recognisable (maven-model-2.0.jar is clear, model-2.0.jar is not). In this case, you usually repeat the last element of the group ID as a mini-namespace. "Internal" modules may omit it for brevity (As the example application shows: http://github.com/brettporter/centrepoint/tree/master/centrepoint/modules/).

    Aside from that, I'd keep them as short as possible.

    You might draw the parallel between Java package and class naming conventions to Maven group and artifact IDs.