views:

38

answers:

3

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?

A: 

You can even go one step further:

-- project
  -- project-module-1
  -- project-module-2

No joking now, this is really a question of taste.

Have a nice day Maksim

Boris Pavlović
Good suggestion.However, in this naming strategy I would prefer to reserve "-" character for separating nested modules. So "project-module-1" would mean that there is parent project "project", which has a child project "module", which has a child project "1".
Maksim Sorokin
Then project-module_1 would do the job.
Boris Pavlović
+2  A: 

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.

Brett Porter
+1  A: 

I usually try to keep module names brief. If the name 'wants' to be long, that's an indication that another nesting level is probably a good idea. So instead of this:

- root
    - api
    - impl
    - security
    - service-soap
    - service-rest
    - client-swing
    - client-web-html
    - client-web-mobile

I'd nest things further:

- root
    - api
    - impl
    - security
    - service
        - soap
        - rest
    - client
        - swing
        - web
            - html
            - mobile

through maven reactor options you can still build the nested modules isolated from the top:

mvn -pl client/web clean install
seanizer