Skip to content

Commit

Permalink
add Gradle Nexus Publish Plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
dtanner committed Sep 13, 2022
1 parent fb8f1db commit 0ee3c63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Publish package
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: -Pversion=${{ env.PUBLISH_VERSION }} publish
arguments: -Pversion=${{ env.PUBLISH_VERSION }} publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
Expand Down
29 changes: 17 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ plugins {
`java-library`
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
}

group = "com.target"
Expand Down Expand Up @@ -40,6 +41,7 @@ tasks {
}
}


java {
withJavadocJar()
withSourcesJar()
Expand Down Expand Up @@ -80,14 +82,9 @@ publishing {
}
developers {
developer {
id.set("chad-moller-target")
name.set("Chad Moller")
email.set("[email protected]")
}
developer {
id.set("dtanner")
name.set("Dan Tanner")
email.set("[email protected]")
id.set("ossteam")
name.set("OSS Office")
email.set("[email protected]")
}
}
scm {
Expand All @@ -103,10 +100,18 @@ signing {
val signingKey: String? by project
val signingPassword: String? by project
if (signingKey.isNullOrBlank() || signingPassword.isNullOrBlank()) {
println("signing key or password is missing. Will disable signing. If you are publishing to sonatype, " +
"export ORG_GRADLE_PROJECT_signingKey and ORG_GRADLE_PROJECT_signingPassword.")
isRequired = false
} else {
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications)
}

0 comments on commit 0ee3c63

Please sign in to comment.