Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A sbt plugin for publishing Scala/Java projects to the Maven central.
Scala Shell
branch: master

README.md

sbt-sonatype plugin

A sbt plugin for publishing your project to the Maven central repository through the REST API of Sonatype Nexus. Deploying artifacts to Sonatype repository is a requiremnt for synchronizing your projects to the Maven central repository. sbt-sonatype plugin enables two-step release of Scala/Java projects.

  • First publishSigned (with sbt-pgp plugin)
  • Next sonatypeRelease to perform the close and release steps in the Sonatype Nexus repository.
  • Done. Your project will be synchoronized to the Maven central in a few hours. No longer need to enter the web interface of Sonatype Nexus repository.

Prerequisites

Usage

sbt-sonatype is available for sbt-0.13.x.

project/plugins.sbt

Import sbt-sonatype plugin and sbt-pgp plugin to use sonatypeRelease and publish-signed commands.

addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "0.2.2")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")

$HOME/.sbt/(sbt-version)/sonatype.sbt

Set Sonatype account information (user name and password) in the global sbt settings. To protect your password, never include this file within your project.

credentials += Credentials("Sonatype Nexus Repository Manager",
        "oss.sonatype.org",
        "(Sonatype user name)",
        "(Sonatype password)")

build.sbt

Import SonatypeKeys._ and add xerial.sbt.Sonatype.sonatypeSettings to your sbt settings. As least you need to set the following keys:

  • profileName
    • This is your Sonatype acount profile name, e.g. org.xerial. If you do not set this value, it will be the same with the organization value.
  • pomExtra
import SonatypeKeys._

// Import default settings. This changes `publishTo` settings to use the Sonatype repository and add several commands for publishing.
sonatypeSettings

// Your project orgnization (package name)
organization := "org.xerial.example" 

// Your profile name of the sonatype account. The default is the same with the organization 
profileName := "org.xerial" 

// Project version. Only release version (w/o SNAPSHOT suffix) can be promoted.
version := "0.1" 

// To sync with Maven central, you need to supply the following information:
pomExtra := {
  <url>(your project URL)</url>
  <!-- License of your choice -->
  <licenses>
    <license>
      <name>Apache 2</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <!-- SCM information. Modify the follwing URLs -->
  <scm>
    <connection>scm:git:github.com/(your repository URL)</connection>
    <developerConnection>scm:git:git@github.com:(your repository URL)</developerConnection>
    <url>github.com/(your repository url)</url>
  </scm>
  <!-- Developer contact information -->
  <developers>
    <developer>
      <id>(your favorite id)</id>
      <name>(your name)</name>
      <url>(your web page)</url>
    </developer>
  </developers>
}

Publishing Your Artifact

The general steps for publishing your artifact to the Central Repository are as follows:

  • publishSigned to deploy your artifact to staging repository at Sonatype.
  • sonatypeClose closes your staging repository at Sonatype. This step verifiles Maven central sync requiement, GPG-signature, javadoc and source code presence, pom.xml settings, etc.
  • sonatypePromote command verifies the closed repository so that it can be synchronized with Maven central.
    • sonatypeRelease will do both sonatypeClose and sonatypePromote in one step.

Note: If your project version has "SNAPSHOT" suffix, your project will be published to the snapshot repository of Sonatype, and you cannot use sonatypeRelease command.

Command Line Usage

Publish a GPG-signed artifact to Sonatype:

$ sbt publishSigned

Do close and promote at once:

$ sbt sonatypeRelease

This command accesses Sonatype Nexus REST API, then sends close and promote commands.

Available Commands

  • sonatypeList
    • Show the list of staging repositories.
  • sonatypeClose (repositoryId)?
    • Close a staging repository.
  • sonatypePromote (repositoryId)?
    • Promote a staging repository.
  • sonatypeDrop (repositoryId)?
    • Drop a staging repository.
  • sonatypeRelease (repositoryId)?
    • Close and promote a staging repository.
  • sonatypeReleaseAll
    • Close and promote all staging repositories (Useful for cross-building projects)
  • sonatypeStagingProfiles
    • Show the list of staging profiles, which include profileName information.
  • sonatypeLog
    • Show the staging activity logs
Something went wrong with that request. Please try again.