• This repository has been archived on 10/Jun/2021
  • Stars
    star
    290
  • Rank 142,981 (Top 3 %)
  • Language
    Groovy
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Gradle plugin for configuring and uploading artifacts to Sonatype Nexus

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.

Usage

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

apply plugin: 'com.bmuschko.nexus'

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 {
         mavenCentral()
     }
     dependencies {
         classpath 'com.bmuschko:gradle-nexus-plugin:2.3.1'
     }
 }

Tasks

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 https://oss.sonatype.org/service/local/staging/deploy/maven2/).
  • snapshotRepositoryUrl: The snapshot repository URL (defaults to https://oss.sonatype.org/content/repositories/snapshots/).

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 {
         ...
     }
 }

Credentials

In your ~/.gradle/gradle.properties 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.

Example

 modifyPom {
     project {
         name 'Gradle Sonatype Nexus plugin'
         description 'Gradle plugin that provides tasks for configuring and uploading artifacts to Sonatype Nexus.'
         url 'https://github.com/bmuschko/gradle-nexus-plugin'
         inceptionYear '2012'

         scm {
             url 'https://github.com/bmuschko/gradle-nexus-plugin'
             connection 'scm:https://[email protected]/bmuschko/gradle-nexus-plugin.git'
             developerConnection 'scm:git://github.com/bmuschko/gradle-nexus-plugin.git'
         }

         licenses {
             license {
                 name 'The Apache Software License, Version 2.0'
                 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                 distribution 'repo'
             }
         }

         developers {
             developer {
                 id 'bmuschko'
                 name 'Benjamin Muschko'
                 email '[email protected]'
             }
         }
     }
 }
 
 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/'
 }

FAQ

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).

More Repositories

1

gradle-docker-plugin

Gradle plugin for managing Docker images and containers.
Java
1,226
star
2

ckad-crash-course

In-depth and hands-on practice for acing the exam.
JavaScript
680
star
3

gradle-tomcat-plugin

Gradle plugin supporting deployment of your web application to an embedded Tomcat web container
Groovy
533
star
4

gradle-in-action-source

Source code for the Manning book "Gradle in Action"
Java
526
star
5

ckad-prep

Exercises demonstrated as part of the video course "Certified Kubernetes Application Developer (CKAD) Prep Course" published by O'Reilly Media.
504
star
6

gradle-cargo-plugin

Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Groovy
254
star
7

cka-crash-course

In-depth and hands-on practice for acing the exam.
Shell
248
star
8

ckad-study-guide

Code example from the book "Certified Kubernetes Application Developer (CKAD) Study Guide" published by O'Reilly Media.
JavaScript
171
star
9

cka-study-guide

Code example from the book "Certified Kubernetes Administrator (CKA) Study Guide" published by O'Reilly Media.
Shell
126
star
10

gradle-android-examples

Demonstrates the use of Gradle for Android projects
Shell
95
star
11

cks-crash-course

In-depth and hands-on practice for acing the exam.
Shell
75
star
12

gradle-clover-plugin

Gradle plugin for generating a code coverage report using Clover
Groovy
73
star
13

go-testing-frameworks

Demonstrates the use of different test frameworks for Go code.
Go
69
star
14

gradle-gae-plugin

Gradle plugin that provides tasks for uploading, running and managing Google App Engine projects
Groovy
64
star
15

gradle-izpack-plugin

Gradle plugin that provides support for packaging applications for the Java platform via IzPack.
Groovy
63
star
16

cje-crash-course

In-depth and hands-on practice for acing the exam.
62
star
17

cta-crash-course

In-depth and hands-on practice for acing the exam.
HCL
52
star
18

gradle-vagrant-plugin

Gradle plugin for managing Vagrant boxes.
Groovy
48
star
19

gradle-initializr

A web-based quickstart generator for Gradle projects
Java
45
star
20

testing-go-projects

The exercises and samples for the training "Testing Go Projects".
Go
39
star
21

docker-for-jvm-projects

The exercises and samples for the training "Docker for JVM projects".
Java
39
star
22

practical-go-modules

The exercises and samples for the training "Practical Go Modules".
Go
36
star
23

todo

A sample To Do web application built with Gradle.
Java
33
star
24

link-verifier

A tool for verifying links in text-based files
Go
27
star
25

testcontainers-integration-testing

The exercises and samples for the training "Integration Testing with Docker and Testcontainers".
Java
26
star
26

grails-google-visualization

Grails plugin that provides a taglib for the interactive charts of the Google Visualization API
Groovy
25
star
27

cje-prep

Exercises demonstrated as part of the video course "Certified Jenkins Engineer (CJE) Prep Course" published by O'Reilly Media.
22
star
28

cks-study-guide

Code example from the book "Certified Kubernetes Security Specialist (CKS) Study Guide" published by O'Reilly Media.
Shell
21
star
29

gradle-javafx-hello-world

Simple Hello World JavaFX project built with Gradle
Groovy
19
star
30

todo-spring-boot

A sample To Do web application built with Gradle and Spring Boot.
Java
19
star
31

go-project-automation

The exercises and samples for the training "Go project automation".
Go
18
star
32

todo-web-service-exercise

A RESTful web service to managing ToDo items.
Java
18
star
33

asciidoctorj-tabbed-code-extension

An AsciidoctorJ extension for rendering code on multiple tabs.
Java
17
star
34

gradle-kubernetes-plugin

Groovy
17
star
35

tooling-api-custom-model

Demonstrates the use of a custom model with Gradle's tooling API.
Java
16
star
36

getting-started-with-bazel

Materials and hand-on exercises for beginner training course on Bazel
Java
15
star
37

cva-crash-course

In-depth and hands-on practice for acing the exam.
HCL
13
star
38

lets-gopher-exercise

A flexible project generator for Go.
Go
12
star
39

jenkins-with-kubernetes

Step by step instructions on how to use the Jenkins Kubernetes plugin for different use cases.
Groovy
11
star
40

kubectl-swiftnp

A kubectl plugin for rendering details of Network Policies.
Go
11
star
41

letsgopher

A simple, yet flexible project generator for Go projects.
Go
10
star
42

groovy-sql-builders

Domain Specific Language for Groovy SQL based on builder API
Groovy
9
star
43

gradle-java2html-plugin

Gradle plugin for turning source code into HTML, RTF, TeX and XHTML using Java2HTML
Groovy
9
star
44

dockerized-spring-boot-app

A dockerized Spring Boot application.
Java
8
star
45

getting-started-bazel

Getting started with Bazel with the help of Java-based examples.
Starlark
8
star
46

rules_java_war

Bazel rules for generating a Java Web Archive (WAR).
Python
8
star
47

bazel-examples

A collection of projects built with Bazel.
Python
7
star
48

gaelyk-jsonlib-plugin

Gaelyk plugin providing JSON support via JSON-lib
Groovy
7
star
49

gradle-junit5-kotlin-dsl

Kotlin
6
star
50

todo-web-service

A simple RESTful web service for managing ToDo items.
Java
6
star
51

whats-new-in-java-11

A test-driven approach to demonstrating new features and APIs in Java 11.
Java
6
star
52

groovy-sql-examples

Groovy SQL examples
Groovy
5
star
53

jenkins-workflow-sample

Demonstrates the use of the Jenkins Workflow plugin to model a build pipeline.
Groovy
4
star
54

junit5-vs-spock-feature-comparison

Compares JUnit 5 with Spock features by example.
Java
4
star
55

favalike

Bookmark manager built with Grails for Google App Engine Java
JavaScript
4
star
56

gradle-junit5-test

Demonstrates use of JUnit 5 Launcher API for discovering and executing tests
Java
4
star
57

gradle-custom-distribution

Custom Gradle distribution for standardizing builds across projects
Groovy
4
star
58

docker-compose-integration-testing

Integration testing using Docker Compose bootstrapped by Gradle.
Java
3
star
59

gradle-release-strategy

Release strategy interferring project version from Git tag.
Java
3
star
60

kubectl-server-version

A kubectl plugin for rendering the Kubernetes server version.
Go
3
star
61

docker-integration-testing

Integration testing against a Docker container as part of a Gradle build.
Java
3
star
62

presentations

Presentation slides and source code
Groovy
3
star
63

jenkins-shared-lib-gradle

A Jenkins shared library for invoking Gradle build steps.
Groovy
3
star
64

vagrant-build-pipeline

Virtual box built with Vagrant that implements a build pipeline
Puppet
2
star
65

todo-docker-swarm

A Vagrant setup for Docker Swarm.
2
star
66

whats-new-in-java-12

A test-driven approach to demonstrating new features and APIs in Java 12.
Java
2
star
67

groovy-payflowpro

Groovy client for PayPal Payflow Pro API
Groovy
2
star
68

todo-web-app

A To Do web application using a RESTful web service as backend.
Java
2
star
69

ide-composable-build

Java
1
star
70

dotfiles

Shell Configuration
Vim Script
1
star
71

idefiles

IDE Configuration
Java
1
star
72

gradle-issue-26802-reproducer

1
star
73

go-on-jenkins

Go
1
star
74

gradle-docker-convention-plugin

Gradle convention plugin for building and pushing Docker images for Node.js applications.
Groovy
1
star
75

trackmybucketlist

Track My Bucket List: Manage Your Life Goals
JavaScript
1
star
76

gradle-in-action-errata

Errata for the Manning book "Gradle in Action"
1
star
77

gradle-node-plugin

Java
1
star
78

bmuschko

1
star
79

passenger

Groovy
1
star
80

gradle-cloudbees-plugin

Gradle plugin that provides support for managing applications and databases on CloudBees RUN@cloud
Groovy
1
star
81

gradle-testkit-gradlebuild

Groovy
1
star
82

testcontainers-spring-boot

A Spring Boot application tested with TestContainers.
Java
1
star