I just want to add a comment regarding naming conventions for the parent POM. Several responses, including the answer by carlspring and the answer by by Steve K, indicated naming the parent pom simply parent:
com.example.foo:parent
com.example.foo:foo
com.example.foo:foo-bar
com.example.foo:foo-bat
com.example.foo:foo-baz
I completely agree with the sentiment, because the parent POM is not a sub-module, which is what foo-parent would seem to imply.
Option 1: com.example.foo:parent
There is however a big problem using simply parent as the artifact ID, besides the fact that it doesn't give much info when searching for it in the Maven Repository. If you import the project into Eclipse, the IDE will use parent for the project name!! This is unsightly, and trying to import two projects that use this convention will cause pain.
But I also don't want to name the artifact foo-parent, because as I mentioned it's not a submodule. Additionally, it will likely be sorted in the middle of the submodules, making it hard to find it in my IDE.
Option 2: com.example.foo:foo-.parent
After much thought and experimentation, I decided I'd like to propose a convention for parent POM artifact IDs: project-.parent. (Yes, this identifier is allowed by Maven.) This shows that the artifact is part of "project", but by beginning with a . it shows that it is a special POM, sort of like a metadata file or a configuration directory. Plus it sorts it to the front of the modules (although not in front of the single project artifact ID). So the module coordinates would look like this:
com.example.foo:foo
com.example.foo:foo-.parent
com.example.foo:foo-bar
com.example.foo:foo-bat
com.example.foo:foo-baz
There's a drawback, though: many tools don't seem to support thing.
It looks like having dots in the artifact ID causes issues with JitPack, JFrog Artifactory, and OSGi Bnd, for example.
Option 3: com.example.foo:foo--parent
I then thought about using foo--parent, or even just foo--. But as - is used as semantically a component separator within the artifact ID, I was worried that a tool might hiccup if two dashes were next to each other. Plus adding a version to the end of the artifact (e.g. foo---1.0.0.jar) would look a little odd.
Option 4: com.example.foo:foo_
Then I stumbled across a blog entry that pointed out that Eclipse has an option for viewing projects hierarchically!! I suddenly realized that my main issue was with a specific use case: that where the aggregate POM is the same as the parent POM, and the main project artifact is in the subdirectory. For example, in repository foo, the project is found inside foo/foo, so what do I name the aggregate POM artifact ID?
Suddenly sorting wasn't such a big deal anymore, because Eclipse would show the root project in a tree.
- For a standalone parent project, I could yield to convention and use
foo-parent.
- For a project in which the main artifact was at the root, there is no problem, as the root artifact ID would simply be named
foo.
So the remaining problem is for a project like this:
…/foo/pom.xml #com.example.foo:???
…/foo/foo/pom.xml #com.example.foo:foo
…/foo/foo-bar/pom.xml #com.example.foo:foo-bar
…/foo/foo-bat/pom.xml #com.example.foo:foo-bat
…/foo/foo-baz/pom.xml #com.example.foo:foo-baz
I would like to give it an artifact ID of foo, but I can't do that as the main foo artifact is in a subdirectory. So for this special case, I'm leaning towards foo_.
…/foo/pom.xml #com.example.foo:foo_
…/foo/foo/pom.xml #com.example.foo:foo
…/foo/foo-bar/pom.xml #com.example.foo:foo-bar
…/foo/foo-bat/pom.xml #com.example.foo:foo-bat
…/foo/foo-baz/pom.xml #com.example.foo:foo-baz
This shows up as foo_ at the root of the tree in Eclipse, and there is not much chance a tool will have problems with a trailing underscore (at least less of a chance than a dot or duplicated dashes).
I'd be interested to get feedback on this discussion and my (current) conclusion.