Giter VIP home page Giter VIP logo

nexus-release-plugin's Introduction

nexus-release-plugin

Automates the release process in Nexus (e.g. Sonatype OSSRH) after upload (publish) has completed.

The main differences compared to the Nexus publish plugin are:

  1. It assumes you use the maven publish plugin to upload your artifacts
  2. Any subproject (module) can use it in contrast to the nexus publish plugin which must be applied on the root project only allowing you to publish modules independently.

To use it you need to add your sonatype username token and password token to ~/.gradle/gradle.properties, e.g:

sonatypeUsername=myUSerToken
sonatypePassword=myPassw0rdToken

Then you use the plugin in your build.gradle as follows:

plugins {
  // your other plugins...
  id 'signing'
  id 'maven-publish'
}

ext.nexusUrl = version.contains("SNAPSHOT")
    ? "https://oss.sonatype.org/content/repositories/snapshots/"
    : "https://oss.sonatype.org/service/local/staging/deploy/maven2/"

pluginManagement {
    repositories {
        maven {
            url = mavenCentral().url
        }
    }
}

publishing {
  publications {
    maven(MavenPublication) {
      from components.java

      artifact(javadocJar)
      artifact(sourcesJar)
      pom {
        name = 'Your project name'
        description = "${project.description}"
        url = "https://github.com/yourGroup/yourProject"
        licenses {
          license {
            name = 'MIT License'
            url = 'https://raw.githubusercontent.com/yourGroup/yourProject/main/LICENSE'
          }
        }
        developers {
          developer {
            id = 'nn'
            name = 'Full Name'
          }
        }
        scm {
          url = 'https://github.com/yourGroup/yourProject/tree/main'
          connection = 'scm:git:https://github.com/yourGroup/yourProject.git'
          developerConnection = 'scm:git:https://github.com/yourGroup/yourProject.git'
        }
      }
    }
  }
  // This will upload to Sonatype Nexus (OSSRH) if credentials are present 
  if (project.ext.properties.sonatypeUsername) {
    repositories {
      maven {
        credentials {
          username = sonatypeUsername
          password = sonatypePassword
        }
        url = nexusUrl
      }
    }
  }
}

// Conditionally apply it if credentials are set allows 
// project members who cannot publish to use the build script smoothly
if (project.ext.properties.sonatypeUsername) {
  apply plugin: NexusReleasePlugin
  nexusReleasePlugin.nexusUrl = nexusUrl
  nexusReleasePlugin.userName = sonatypeUsername
  nexusReleasePlugin.password = sonatypePassword
}

nexus-release-plugin's People

Contributors

pernyfelt avatar

Watchers

 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.