only enable signing if not snapshot OR running 'publish' task
This commit is contained in:
parent
6670346890
commit
acfaaec754
1 changed files with 65 additions and 62 deletions
|
@ -16,87 +16,90 @@
|
||||||
*/
|
*/
|
||||||
package buildsrc.conventions
|
package buildsrc.conventions
|
||||||
|
|
||||||
import org.gradle.api.tasks.bundling.Jar
|
|
||||||
import org.gradle.kotlin.dsl.creating
|
|
||||||
import org.gradle.kotlin.dsl.getValue
|
|
||||||
import org.gradle.kotlin.dsl.version
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("maven-publish")
|
id("maven-publish")
|
||||||
id("signing")
|
id("signing")
|
||||||
id("org.jetbrains.dokka")
|
id("org.jetbrains.dokka")
|
||||||
}
|
}
|
||||||
|
|
||||||
val gitHub = "ethauvin/${rootProject.name}"
|
val gitHub = "ethauvin/${rootProject.name}"
|
||||||
val mavenUrl = "https://github.com/$gitHub"
|
val mavenUrl = "https://github.com/$gitHub"
|
||||||
|
val isSnapshotVersion = { project.version.toString().contains("SNAPSHOT") }
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
withType<MavenPublication>().configureEach {
|
withType<MavenPublication>().configureEach {
|
||||||
pom {
|
pom {
|
||||||
name.set("UrlEncoder for Kotlin")
|
name.set("UrlEncoder for Kotlin")
|
||||||
description.set(project.description)
|
description.set(project.description)
|
||||||
url.set(mavenUrl)
|
url.set(mavenUrl)
|
||||||
licenses {
|
licenses {
|
||||||
license {
|
license {
|
||||||
name.set("The Apache License, Version 2.0")
|
name.set("The Apache License, Version 2.0")
|
||||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
developers {
|
||||||
|
developer {
|
||||||
|
id.set("gbevin")
|
||||||
|
name.set("Geert Bevin")
|
||||||
|
email.set("gbevin@uwyn.com")
|
||||||
|
url.set("https://github.com/gbevin")
|
||||||
|
}
|
||||||
|
developer {
|
||||||
|
id.set("ethauvin")
|
||||||
|
name.set("Erik C. Thauvin")
|
||||||
|
email.set("erik@thauvin.net")
|
||||||
|
url.set("https://erik.thauvin.net/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scm {
|
||||||
|
connection.set("scm:git://github.com/$gitHub.git")
|
||||||
|
developerConnection.set("scm:git@github.com:$gitHub.git")
|
||||||
|
url.set(mavenUrl)
|
||||||
|
}
|
||||||
|
issueManagement {
|
||||||
|
system.set("GitHub")
|
||||||
|
url.set("$mavenUrl/issues")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
developers {
|
|
||||||
developer {
|
|
||||||
id.set("gbevin")
|
|
||||||
name.set("Geert Bevin")
|
|
||||||
email.set("gbevin@uwyn.com")
|
|
||||||
url.set("https://github.com/gbevin")
|
|
||||||
}
|
|
||||||
developer {
|
|
||||||
id.set("ethauvin")
|
|
||||||
name.set("Erik C. Thauvin")
|
|
||||||
email.set("erik@thauvin.net")
|
|
||||||
url.set("https://erik.thauvin.net/")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scm {
|
|
||||||
connection.set("scm:git://github.com/$gitHub.git")
|
|
||||||
developerConnection.set("scm:git@github.com:$gitHub.git")
|
|
||||||
url.set(mavenUrl)
|
|
||||||
}
|
|
||||||
issueManagement {
|
|
||||||
system.set("GitHub")
|
|
||||||
url.set("$mavenUrl/issues")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
repositories {
|
||||||
repositories {
|
maven(
|
||||||
maven(
|
if (isSnapshotVersion()) {
|
||||||
if (project.version.toString().contains("SNAPSHOT")) {
|
uri("https://oss.sonatype.org/content/repositories/snapshots/")
|
||||||
uri("https://oss.sonatype.org/content/repositories/snapshots/")
|
} else {
|
||||||
} else {
|
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
||||||
uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
|
}
|
||||||
}
|
) {
|
||||||
) {
|
name = "ossrh"
|
||||||
name = "ossrh"
|
credentials(PasswordCredentials::class)
|
||||||
credentials(PasswordCredentials::class)
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
signing {
|
signing {
|
||||||
useGpgCmd()
|
useGpgCmd()
|
||||||
sign(publishing.publications)
|
sign(publishing.publications)
|
||||||
}
|
|
||||||
|
|
||||||
|
setRequired({
|
||||||
|
!isSnapshotVersion() || gradle.taskGraph.hasTask("publish")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
tasks.withType<Sign>().configureEach {
|
||||||
|
val signingRequiredPredicate = provider { signing.isRequired }
|
||||||
|
onlyIf { signingRequiredPredicate.get() }
|
||||||
|
}
|
||||||
|
|
||||||
// https://youtrack.jetbrains.com/issue/KT-46466
|
// https://youtrack.jetbrains.com/issue/KT-46466
|
||||||
val signingTasks = tasks.withType<Sign>()
|
val signingTasks = tasks.withType<Sign>()
|
||||||
tasks.withType<AbstractPublishToMaven>().configureEach {
|
tasks.withType<AbstractPublishToMaven>().configureEach {
|
||||||
dependsOn(signingTasks)
|
dependsOn(signingTasks)
|
||||||
}
|
}
|
||||||
|
|
||||||
val javadocJar by tasks.registering(Jar::class) {
|
val javadocJar by tasks.registering(Jar::class) {
|
||||||
dependsOn(tasks.dokkaJavadoc)
|
dependsOn(tasks.dokkaJavadoc)
|
||||||
from(tasks.dokkaJavadoc)
|
from(tasks.dokkaJavadoc)
|
||||||
archiveClassifier.set("javadoc")
|
archiveClassifier.set("javadoc")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue