Skip to content

Commit

Permalink
Improve signing config
Browse files Browse the repository at this point in the history
  • Loading branch information
MinnDevelopment committed Jan 1, 2024
1 parent e85070f commit 8e5076e
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@ tasks.getByName("dokkaHtml", DokkaTask::class) {
// Publishing //
////////////////


fun getProjectProperty(name: String) = project.properties[name] as? String


// Generate pom file for maven central

fun generatePom(): MavenPom.() -> Unit {
Expand Down Expand Up @@ -234,20 +230,19 @@ publishing.publications {
}

val signingKey: String? by project

if (signingKey != null) {
signing {
useInMemoryPgpKeys(signingKey, null)
sign(*publishing.publications.toTypedArray())
}
}

val signingKeyId: String? by project
val ossrhUser: String? by project
val ossrhPassword: String? by project
val stagingProfile: String? by project

val enablePublishing = ossrhUser != null && ossrhPassword != null && stagingProfile != null

signing {
useInMemoryPgpKeys(signingKeyId, signingKey, "")
sign(*publishing.publications.toTypedArray())
isRequired = enablePublishing
}

if (enablePublishing) {
nexusPublishing {
repositories.sonatype {
Expand All @@ -270,7 +265,7 @@ val rebuild = tasks.register<Task>("rebuild") {

// Only enable publishing task for properly configured projects
val publishingTasks = tasks.withType<PublishToMavenRepository> {
enabled = ossrhUser?.isNotEmpty() == true || name.contains("local", true)
enabled = ossrhUser?.isNotEmpty() == true
mustRunAfter(rebuild)
dependsOn(rebuild)
}

0 comments on commit 8e5076e

Please sign in to comment.