if I use the maven-publish
plugin to upload my artifacts, how could I sign my POM file.
This is the code:
plugins {
maven
`maven-publish`
id("signing")
id("org.jetbrains.dokka") version "1.4.10.2"
}
repositories {
mavenCentral()
}
group = "my.group"
version = "1.0.0"
tasks {
val sourcesJar by creating(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by creating(Jar::class) {
dependsOn.add(dokkaJavadoc)
archiveClassifier.set("javadoc")
from(dokkaJavadoc)
}
artifacts {
archives(sourcesJar)
archives(javadocJar)
archives(jar)
}
}
@Suppress("UnstableApiUsage")
signing {
useGpgCmd()
sign(configurations.archives.get())
}
@Suppress("UnstableApiUsage")
publishing {
repositories {
maven {
val releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
val snapshotsRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/snapshots/"
url = uri(if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl)
credentials {
username=project.properties["ossrhUser"].toString()
password=project.properties["ossrhPassword"].toString()
}
}
}
publications {
create<MavenPublication>("maven") {
groupId = "my.group"
artifactId = "my-lib"
version = "1.0.0"
pom {
name.set("my-lib")
description.set("desc")
url.set("...")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("Balage1551")
name.set("Balazs Vissy")
email.set("...")
}
}
scm {
connection.set("...")
developerConnection.set("...")
url.set("...")
}
}
}
}
}
When I run publish
all goes well, the signed jars are uploaded, but the verification fails with missing ASC file for POM.
Earlier, in gradle 4, when I used maven
and Groovy, I was able to add to my code:
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
to my uploadArchives task.
How can I do it with Kotlin DSL and with the publishing structure?