Publishing to Maven Central

Publishing to Maven Central

This is just a quick post to highlight how easy it can be to publish libraries to Maven Central.

Demise of JCenter

In case you missed it, JCenter is shutting down in May 2021:

Into the Sunset: Bintray, JCenter, GoCenter, and ChartCenter
To streamline the productivity of the JFrog Platform we will be sunsetting Bintray (including JCenter), GoCenter, and ChartCenter services on May 1st, 2021.

With the demise of JCenter, the need to publish somewhere else is probably something which is top of mind for many library developers. This post won't go into the nuts and bolts of how, but instead point to existing resources which will help.

For me, Maven Central is the obvious place to now publish your libraries.

Why not Jitpack?

I agree with the points Saket Narayan made here:

Publishing to Maven Central

Márton Braun's post goes into detail of how to setup your Sonatype account, and publish your first library:

Publishing Android libraries to MavenCentral in 2021
Introduction This is an updated version of an article published two years ago on This new version supports non-Android libr…

Publish plugin

Marton uses an updated version of my gradle-mvn-push script (I think), but I've personally moved to using the gradle-maven-publish-plugin plugin by Niklas Baudy instead:

Gradle plugin that configures an uploadArchives task to automatically upload all of your Java, Kotlin or Android libraries to any Maven instance. - vanniktech/gradle-maven-publish-plugin

It handles all of the docs source sets for you, as well as support for Dokka if you're using Kotlin. Highly recommended! 🏅

Automated closing + releasing

Using Maven Central and Sonatype requires you to manually close and release your library version. Personally I like this step, as it keeps me in control of exactly what is released. This is especially important on Maven Central, as anything which is published is immutable. You can't change it.

But, I do understand that some people want to automate this as much as possible, so there are a few ways to automate the release:

The gradle-maven-publish-plugin I mentioned earlier has support for this. Once setup you can call ./gradlew closeAndReleaseRepository .

Alternatively, Saket has created a standalone command-line tool which enables similar, called Startship:

Never open sonatype’s website again for releasing your libraries. - saket/startship


If you'd like to look at some examples for how to setup your library to publish to Maven Central, here's a few below:

A collection of extension libraries for Jetpack Compose - chrisbanes/accompanist
Insetter is a library to help apps handle WindowInsets more easily - chrisbanes/insetter

If you know of any other open source examples, let me know.