Skip to content

Commit

Permalink
switch marcphilipp.nexus-publish -> gradle-nexus.publish-plugin
Browse files Browse the repository at this point in the history
Meanwhile there exists the official `io.github.gradle-nexus.publish-plugin` to upload ArchUnit release artifacts to Sonatype. This plugins creates a staging repository and provides the repository id so that subsequent tasks can use them.

Signed-off-by: Nils-Oliver Linden <nils-oliver.linden@tngtech.com>
  • Loading branch information
Nils-Oliver Linden authored and codecholeric committed Aug 22, 2021
1 parent 6efdf51 commit ed88c55
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
19 changes: 13 additions & 6 deletions build-steps/release/check-uploaded-artifacts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ apply from: scriptRelativePath(this, 'vcs-utils.gradle')
apply from: scriptRelativePath(this, 'archunit-examples-utils.gradle')

File scriptRoot = currentScriptRootOf this
def rootUrl = {
if (!project.hasProperty('tngRepoId')) {
throw new IllegalArgumentException(
'You must pass the repo id (see Sonatype Repository Manager -> comtngtech-${repoId}) as parameter, e.g. -P tngRepoId=1162')
}
"https://oss.sonatype.org/service/local/repositories/comtngtech-${tngRepoId}/content/com/tngtech/archunit"

ext {
tngRepoId = project.findProperty('tngRepoId')
}

def rootUrl = {
"https://oss.sonatype.org/service/local/repositories/${tngRepoId}/content/com/tngtech/archunit"
}

def createArtifactUrl = { String artifactId ->
Expand Down Expand Up @@ -119,6 +120,10 @@ def checkArtifactContent = { Project project, JarFile jarFile ->
}

task checkUploadedArtifacts {
doFirst {
tngRepoId = tngRepoId ?: closeSonatypeStagingRepository.stagingRepositoryId.get()
}

doLast {
releaseProjects.each { Project project ->
checkPom(project.name)
Expand All @@ -130,6 +135,7 @@ task checkUploadedArtifacts {
}
}
}
closeSonatypeStagingRepository.finalizedBy(checkUploadedArtifacts)

releaseProjects.each { Project project ->
def task = project.task(['dependsOn': project.build], 'checkArtifact') {
Expand Down Expand Up @@ -191,3 +197,4 @@ task testRelease() {
testExampleProject('example-junit5')
}
}
closeSonatypeStagingRepository.finalizedBy(testRelease)
27 changes: 11 additions & 16 deletions build-steps/release/publish.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
ext.isReleaseVersion = !project.version.endsWith("-SNAPSHOT")

if (!hasProperty("sonatypeUsername")) {
ext.sonatypeUsername = ""
}
if (!hasProperty("sonatypePassword")) {
ext.sonatypePassword = ""
apply plugin: "io.github.gradle-nexus.publish-plugin"

nexusPublishing {
packageGroup = 'com.tngtech'
repositories {
sonatype {
username = findProperty("sonatypeUsername")
password = findProperty("sonatypePassword")
}
}
}

releaseProjects*.with {
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "de.marcphilipp.nexus-publish"

tasks.withType(GenerateModuleMetadata) {
enabled = false // the meta-data does not match the way the Maven artifacts are composed and thus is broken
Expand Down Expand Up @@ -76,20 +80,11 @@ releaseProjects*.with {
}
}
}

// respective username and password can be configured in ~/.gradle/gradle.properties
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
nexusPublishing {
repositories {
sonatype()
}
}
}
}

signing {
required {
isReleaseVersion && gradle.taskGraph.hasTask('publish') && project.hasProperty('sonatypeUsername')
isReleaseVersion && gradle.taskGraph.hasTask('publish')
}
def signingKey = findProperty("signingKey")
def signingPassword = findProperty("signingPassword")
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0' apply false
id 'com.github.spotbugs' version '4.7.3' apply false
id "de.marcphilipp.nexus-publish" version "0.4.0" apply false
id "io.github.gradle-nexus.publish-plugin" version "1.1.0" apply false
id "com.diffplug.spotless" version "5.14.2" apply false
}

Expand Down

0 comments on commit ed88c55

Please sign in to comment.