Giter Site home page Giter Site logo

sbt-sonatype's Introduction

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

sbt-sonatype's People

Contributors

mosabua avatar tkawachi avatar xerial avatar xuwei-k avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.