Skip to content
This repository has been archived by the owner. It is now read-only.


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Gradle Sonatype Nexus plugin Build Status

Sonatype Logo

This project reached end of life (EOL) status due to its incompatibility with Gradle 7.0. No more feature requests will be considered. Bug fixes will be accepted as long as they will be compatible with earlier versions of Gradle.

The plugin provides support for configuring and uploading artifacts to Sonatype Nexus. It can be configured to deploy to a self-hosted instance of Nexus or Sonatype OSS. The default setup is to publish to Sonatype OSS. Currently, Java and Groovy project artifact generation is supported. In addition to the JAR and POM file artifacts containing the JavaDocs and source files are created. Signing the artifacts is optional.


To use the Sonatype Nexus plugin, include in your build script:

apply plugin: ''

The plugin JAR needs to be defined in the classpath of your build script. It is directly available on Bintray. Alternatively, you can download it from GitHub and deploy it to your local repository. The following code snippet shows an example on how to retrieve it from Maven Central:

 buildscript {
     repositories {
     dependencies {
         classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'


The Nexus plugin can add three tasks to your project:

  • javadocJar: Assembles a jar archive containing the generated Javadoc API documentation of this project (added by default).
  • sourcesJar: Assembles a jar archive containing the main sources of this project (added by default).
  • testsJar: Assembles a jar archive containing the test sources of this project.

The output of all tasks is added to the archives configuration. To tell the plugin that any of these tasks should be added to the project or removed, you will need to set a specific extension property.

Additionally, it applies the Maven plugin as well as signing in order to leverage maven's install and uploadArchives tasks.

Extension properties

The plugin defines the following extension properties in the extraArchive closure:

  • javadoc: Adds Javadoc JAR task to project (defaults to true).
  • sources: Adds sources JAR task to project (defaults to true).
  • tests: Adds test sources JAR task to project (defaults to false).

The plugin defines the following extension properties in the nexus closure:

  • sign: Specifies whether to sign the artifacts using the signing plugin (defaults to true).
  • configuration: The custom configuration used to publish artifacts (defaults to archives).
  • repositoryUrl: The stable release repository URL (defaults to
  • snapshotRepositoryUrl: The snapshot repository URL (defaults to

Additional configuration

POM customization

In addition to the convention properties the automatically generated POM file can be modified. To provide the data for the POM generation specify the information within the configuration element modifyPom.project.

 modifyPom {
     project {


In your ~/.gradle/ you will need to set the mandatory Nexus credentials required for uploading your artifacts.

 nexusUsername = yourUsername
 nexusPassword = yourPassword

If you don't specify one of these properties, the plugin will prompt your for their values in the console.


 modifyPom {
     project {
         name 'Gradle Sonatype Nexus plugin'
         description 'Gradle plugin that provides tasks for configuring and uploading artifacts to Sonatype Nexus.'
         url ''
         inceptionYear '2012'

         scm {
             url ''
             connection 'scm:'
             developerConnection 'scm:git://'

         licenses {
             license {
                 name 'The Apache Software License, Version 2.0'
                 url ''
                 distribution 'repo'

         developers {
             developer {
                 id 'bmuschko'
                 name 'Benjamin Muschko'
                 email ''
 extraArchive {
     sources = false
     tests = true
     javadoc = false

 nexus {
     sign = true
     repositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal/'
     snapshotRepositoryUrl = 'http://localhost:8081/nexus/content/repositories/internal-snapshots/'


How do I publish my artifacts to the Central Repository aka Maven Central aka Sonatype OSS?

By default the plugin is configured to upload your artifacts to the release and snapshot repository URLs of Sonatype OSS. There's no additional configuration required. If you want to tweak the automatically generated POM file please you the modifyPom closure. Make sure to stick to the process described in the Central Repository Documentation.

Is it possible to automatically publish artifacts to Maven Central without any manual steps in the Nexus GUI (e.g. from CI server)?

It is beyond the scope of this plugin, but there is a dedicated 3rd-party plugin gradle-nexus-staging-plugin which allows for releasing and promoting artifacts to Maven Central directly from Gradle. It also seamlessly integrates with gradle-nexus-plugin (e.g. allows to reuse provided credentials).


Gradle plugin for configuring and uploading artifacts to Sonatype Nexus








No packages published