Skip to content
Gradle Plugin that explicitly creates a Staging Repository before publishing to Nexus.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Nexus Publish Plugin

Build Status Gradle Plugin Portal

Gradle Plugin that explicitly creates a Staging Repository before publishing to Nexus. This solves the problem that frequently occurs when uploading to Nexus from Travis, namely split staging repositories.


The plugin does the following:

  • Apply the maven-publish plugin
  • configure a Maven artifact repository called nexus (customizable via the repositoryName property)
  • create a initializeNexusStagingRepository task that starts a new staging repository in case the project's version does not end with -SNAPSHOT (customizable via the useStaging property) and sets the URL of the nexus repository accordingly. In case of a multi-project build, all subprojects with the same serverUrl will use the same staging repository.
  • if the plugin is applied on the root project, the stagingRepositoryId on its extension is set to the id of the newly created staging repository, this way it does not depend on exactly one open staging repository being available.
  • make all publishing tasks for the nexus repository depend on the initializeNexusStagingRepository task.
  • create a publishToNexus lifecycle task that depends on all publishing tasks for the nexus repository.

Groovy DSL

plugins {
    id "java-library"
    id "" version "0.2.0"

publishing {
    publications {
        mavenJava(MavenPublication) {

nexusPublishing {
    serverUrl = uri("") // defaults to
    snapshotRepositoryUrl = uri("") // defaults to
    username = "your-username" // defaults to["nexusUsername"]
    password = "your-password" // defaults to["nexusPassword"]

Kotlin DSL

plugins {
    id("") version "0.2.0"

publishing {
    publications {
        create<MavenPublication>("mavenJava") {

nexusPublishing {
    serverUrl.set(uri("")) // defaults to
    snapshotRepositoryUrl.set(uri("")) // defaults to
    username.set("your-username") // defaults to["nexusUsername"]
    password.set("your-password") // defaults to["nexusPassword"]

If the plugin is applied on the root project, the following default values change:

Property Default value
packageGroup rootProject.nexusStaging.packageGroup
stagingProfileId rootProject.nexusStaging.stagingProfileId
username rootProject.nexusStaging.username
password rootProject.nexusStaging.password

This reuses the values specified for the nexusStaging block, so you don't have to specify them twice.

You can’t perform that action at this time.