Release to Maven Central

Maven Central is the place where developers go to get Java libraries, and it is where any library that a user is expected to use should be uploaded. Requiring users to retrieve a dependency from a different location requires them to manually introduce new configuration into their project files to specify this new location, and there is rarely an argument for introducing this additional friction.

It's important to note that Maven Central is not just for the Maven build tool - build tools such as Gradle also know how to look up dependencies in Maven Central.

Being the primary location for Java artifacts, Maven Central has many mirrors. This reduces the likelihood of a dependency becoming unavailable due to a single point of failure.

Unless there is a very good reason to not distribute via Maven Central, this should be the default means of releasing artifacts to the world.

What should my Maven Co-ordinates be?

I often feel anguish when I look at companies that are prolific releasers of Java libraries to Maven. They often have a different group ID for each library, and no clear pattern for the artifact ID. This makes it very difficult to find the library you are looking for, and makes it difficult to know what the library is for.

I always liken a group ID to a container for a set of related libraries, and the artifact ID to the name of the library. For example, if I was to release a library that contained a set of utilities for working with the Java Collections API, I might use the Maven co-ordinates com.companyname:collection-utils. If I could foresee a future where I would release a number of libraries that were related to collections, I might use the group ID com.companyname.collections to indicate that this is a container for a set of related libraries. In the Azure SDK for Java I do this with group IDs for com.azure (for the primary set of libraries), and then separate buckets for com.azure.spring and com.azure.android.

The point I want to make here is this: in most cases your library is not special. It should not get its own group ID, if it is going to be the only library in there. It is better to have your library be part of the larger set of libraries that your company produces, and to have a clear naming convention for the artifact ID.