Skip to content

Commit

Permalink
Update build.gradle
Browse files Browse the repository at this point in the history
  • Loading branch information
mjfryc authored Nov 2, 2021
1 parent 484a030 commit ef1bb5a
Showing 1 changed file with 27 additions and 22 deletions.
49 changes: 27 additions & 22 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'io.github.mjfryc'
version '0.1.21'
version '0.1.22'

repositories {
mavenCentral()
Expand All @@ -25,27 +25,6 @@ java {
withJavadocJar()
}

def hasSigningKey = System.getenv("GPG_PASSWORD") != null && System.getenv("GPG_PRIVATE_KEY") != null
if (hasSigningKey) {
System.out.println("GPG key and password found. Signing maven publications.")
doSign(project)
} else {
System.out.println("GPG key or password not found. Signing is skipped.")
}

void doSign(Project project) {
project.signing {
required { project.gradle.taskGraph.hasTask("required") }
def signingKey = System.getenv("GPG_PRIVATE_KEY")
def signingPassword = System.getenv("GPG_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
//sign configurations.archives
//sign publishing.publications.maven
sign publishing.publications.gpr
//sign project
}
}

project.plugins.withType(MavenPublishPlugin).all {
PublishingExtension publishing = project.extensions.getByType(PublishingExtension)
publishing.publications.withType(MavenPublication).all { mavenPublication ->
Expand Down Expand Up @@ -105,3 +84,29 @@ publishing {
}
}
}

def hasSigningKey = System.getenv("GPG_PASSWORD") != null && System.getenv("GPG_PRIVATE_KEY") != null
if (hasSigningKey) {
System.out.println("GPG key and password found. Signing maven publications.")
doSign(project)
} else {
System.out.println("GPG key or password not found. Signing is skipped.")
}

void doSign(Project project) {
println("Signing publications. All etries:")
publishing.publications.all {
println(" Publication: " + it.name)
}

project.signing {
required { project.gradle.taskGraph.hasTask("required") }
def signingKey = System.getenv("GPG_PRIVATE_KEY")
def signingPassword = System.getenv("GPG_PASSWORD")
useInMemoryPgpKeys(signingKey, signingPassword)
//sign configurations.archives
//sign publishing.publications.maven
sign publishing.publications.gpr
//sign project
}
}

0 comments on commit ef1bb5a

Please sign in to comment.