Skip to content

How to release with Sonatype

jvican edited this page Oct 6, 2017 · 6 revisions

Release with Sonatype

You don't have a Sonatype account

If links are down, check the official instructions site here. It also has videos that explain the procedure.

The tutorial says that it can take up 2 business days. In my experience, it rarely takes more than one business day.

After you've created your sonatype account, go read the next steps in the You have a sonatype account section.

You have a sonatype account

Set up the sbt build

If you want to publish with Sonatype globally, first you need to configure the underlying publisher that will be used by sbt-release-early. Add the following line to your build.sbt file:

releaseEarlyWith in Global := SonatypePublisher

(By default, releaseEarlyWith defaults to BintrayPublisher and is scoped in Global.)

If you want a more fine-grained configuration, releasing to Sonatype only concrete modules, you can scope the previous line to whichever project you want and it will work. But do make sure to remove in Global from the previous line line: releaseEarlyWith := SonatypePublisher.

Set up the CI with the credentials

Check the tutorial in How to set up your CI.

Meta info

Avoid waiting until the package has hit Maven Central

You can depend immediately on a package that has been published to Sonatype by adding the Sonatype staging repository either globally or in your project's build.sbt:

resolvers += Resolver.sonatypeRepo("releases")

Make sure you scope this setting correctly. It's usually done globally (in Global)if you don't redefine resolvers elsewhere. If you do, scope if at the place where the redefinition takes place.

Disadvantages

There are two disadvantages of using Sonatype as your publisher.

  1. You do not have fine-grained control over organizations and rights like Bintray does.
  2. Publishing to Sonatype takes more time because it cannot be done in parallel, unlike Bintray:
    1. Remove excessive coupling between sonatype commands and publishSigned
    2. Is it possible to turn the commands into tasks

If you'd like this to change, please give a thumbs up to each of those issues and let the maintainer know that this poses a problem to you. It does not end the world though. IMO, Sonatype is still superior than Bintray for most of the cases.

Read up on Bintray's disadvantages if you're interested to see how it fares.