Home

Awesome

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.

⚠️ Deprecation 🛑

This plugin is now deprecated and no longer maintained. The Gradle Nexus Publish Plugin is the successor of this plugin and adds additional tasks to close and release staging repositories.

Usage

The plugin does the following:

Publishing to Maven Central via Sonatype OSSRH

In order to publish to Maven Central via Sonatype's OSSRH Nexus, you simply need to add the sonatype() repository like in the example below. It's nexusUrl and snapshotRepositoryUrl are pre-configured.

nexusPublishing {
    repositories {
        sonatype()
    }
}

In addition, you need to set the sonatypeUsername and sonatypePassword project properties, e.g. in ~/.gradle/gradle.properties. Alternatively, you can configure username and password in the sonatype block:

nexusPublishing {
    repositories {
        sonatype {
            username = "your-username"
            password = "your-password"
        }
    }
}

Finally, call publishToSonatype to publish all publications to Sonatype's OSSRH Nexus.

Full example

Groovy DSL

plugins {
    id "java-library"
    id "de.marcphilipp.nexus-publish" version "0.3.0"
}

publishing {
    publications {
        mavenJava(MavenPublication) {
            from(components.java)
        }
    }
}

nexusPublishing {
    repositories {
        myNexus {
            nexusUrl = uri("https://your-server.com/staging")
            snapshotRepositoryUrl = uri("https://your-server.com/snapshots")
            username = "your-username" // defaults to project.properties["myNexusUsername"]
            password = "your-password" // defaults to project.properties["myNexusPassword"]
        }
    }
}

Kotlin DSL

plugins {
    `java-library`
    id("de.marcphilipp.nexus-publish") version "0.3.0"
}

publishing {
    publications {
        create<MavenPublication>("mavenJava") {
            from(components["java"])
        }
    }
}

nexusPublishing {
    repositories {
        create("myNexus") {
            nexusUrl.set(uri("https://your-server.com/staging"))
            snapshotRepositoryUrl.set(uri("https://your-server.com/snapshots"))
            username.set("your-username") // defaults to project.properties["myNexusUsername"]
            password.set("your-password") // defaults to project.properties["myNexusPassword"]
        }
    }
}

Integration with the Nexus Staging Plugin

If the io.codearte.nexus-staging plugin is applied on the root project, the following default values change:

PropertyDefault value
packageGrouprootProject.nexusStaging.packageGroup
stagingProfileIdrootProject.nexusStaging.stagingProfileId
usernamerootProject.nexusStaging.username
passwordrootProject.nexusStaging.password

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

HTTP Timeouts

You can configure the connectTimeout and clientTimeout properties on the nexusPublishing extension to set the connect and read/write timeouts (both default to 1 minute). Good luck!