Skip to content

Commit

Permalink
Add tasks for closing and releasing Sonatype release repository
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Apr 25, 2018
1 parent 4640b08 commit 73c9598
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions gradle/publishing.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import io.codearte.gradle.nexus.BaseStagingTask
import io.codearte.gradle.nexus.NexusStagingPlugin

import javax.naming.ConfigurationException

buildscript {
repositories {
gradlePluginPortal()
}
dependencies {
classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0'
}
}

def releaseVersion = !version.toString().endsWith('-SNAPSHOT')

ext {
Expand All @@ -13,6 +25,8 @@ ext {
project.findProperty('sonatype.username')
sonatypePassword = project.findProperty('javacord.sonatype.password') ?:
project.findProperty('sonatype.password')
sonatypeStagingProfileId = project.findProperty('javacord.sonatype.stagingProfileId') ?:
project.findProperty('sonatype.stagingProfileId')
}

allprojects {
Expand Down Expand Up @@ -88,3 +102,36 @@ allprojects {
sign publishing.publications
}
}

apply plugin: NexusStagingPlugin
// remove superfluous tasks from NexusStagingPlugin
tasks.removeAll([promoteRepository, closeAndPromoteRepository, getStagingProfile])

nexusStaging {
stagingProfileId sonatypeStagingProfileId
username sonatypeUsername
password sonatypePassword
}

// make sure the staging tasks are run after any publishing tasks if both are to be run
tasks.withType(BaseStagingTask) {
mustRunAfter allprojects.tasks*.withType(PublishToMavenRepository)

doFirst {
if (!sonatypeStagingProfileId) {
throw new ConfigurationException(
'Please set the Sonatype staging profile id with project property "sonatype.stagingProfileId" ' +
'or "javacord.sonatype.stagingProfileId". If both are set, the latter will be effective.')
}
if (!sonatypeUsername) {
throw new ConfigurationException(
'Please set the Sonatype username with project property "sonatype.username" ' +
'or "javacord.sonatype.username". If both are set, the latter will be effective.')
}
if (!sonatypePassword) {
throw new ConfigurationException(
'Please set the Sonatype password with project property "sonatype.password" ' +
'or "javacord.sonatype.password". If both are set, the latter will be effective.')
}
}
}

0 comments on commit 73c9598

Please sign in to comment.