Skip to content

Commit

Permalink
Simplify signing config (#4971)
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Jun 20, 2022
1 parent 06ee239 commit ecd28cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
10 changes: 6 additions & 4 deletions build-logic/src/main/kotlin/packaging.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ if (signingKey.isNullOrBlank() || signingPwd.isNullOrBlank()) {
logger.info("Signing disabled as the GPG key was not found")
} else {
logger.info("GPG Key found - Signing enabled")
signing {
useInMemoryPgpKeys(signingKey, signingPwd)
publishing.publications.forEach(::sign)
}
}

signing {
useInMemoryPgpKeys(signingKey, signingPwd)
sign(publishing.publications)
isRequired = !(signingKey.isNullOrBlank() || signingPwd.isNullOrBlank())
}

val String.byProperty: String? get() = findProperty(this) as? String
15 changes: 0 additions & 15 deletions detekt-gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
`java-gradle-plugin`
`java-test-fixtures`
idea
signing
alias(libs.plugins.pluginPublishing)
// We use this published version of the Detekt plugin to self analyse this project.
id("io.gitlab.arturbosch.detekt") version "1.20.0"
Expand Down Expand Up @@ -166,20 +165,6 @@ tasks.withType<Sign>().configureEach {
notCompatibleWithConfigurationCache("https://github.com/gradle/gradle/issues/13470")
}

val signingKey = "SIGNING_KEY".byProperty
val signingPwd = "SIGNING_PWD".byProperty
if (signingKey.isNullOrBlank() || signingPwd.isNullOrBlank()) {
logger.info("Signing disabled as the GPG key was not found")
} else {
logger.info("GPG Key found - Signing enabled")
afterEvaluate {
signing {
useInMemoryPgpKeys(signingKey, signingPwd)
publishing.publications.forEach(::sign)
}
}
}

afterEvaluate {
publishing {
publications.filterIsInstance<MavenPublication>().forEach {
Expand Down

0 comments on commit ecd28cf

Please sign in to comment.