aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-11-12 17:51:42 +0100
committerKamil Doległo <9080183+kamildoleglo@users.noreply.github.com>2020-11-13 19:18:04 +0100
commite03aed7331756eaef766c7306bd033c84f7fd815 (patch)
tree6771eb98d35e0e817438d5b1fb7114accc7d473f
parenteba25082251b5cc9b6e398e780b8092f2bb9fb9c (diff)
downloaddokka-e03aed7331756eaef766c7306bd033c84f7fd815.tar.gz
dokka-e03aed7331756eaef766c7306bd033c84f7fd815.tar.bz2
dokka-e03aed7331756eaef766c7306bd033c84f7fd815.zip
Add additional info to POM files and sign the artifacts for MavenCentral deployment
-rw-r--r--build.gradle.kts1
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/publication.kt50
2 files changed, 49 insertions, 2 deletions
diff --git a/build.gradle.kts b/build.gradle.kts
index a1b3a202..dcbba232 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -43,6 +43,7 @@ subprojects {
apply {
plugin("org.jetbrains.kotlin.jvm")
plugin("java")
+ plugin("signing")
plugin("org.jetbrains.dokka")
}
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
index c6b74746..6c2f71a6 100644
--- a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
+++ b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
@@ -3,6 +3,7 @@ package org.jetbrains
import com.github.jengelman.gradle.plugins.shadow.ShadowExtension
import com.jfrog.bintray.gradle.BintrayExtension
import org.gradle.api.Project
+import org.gradle.api.provider.Provider
import org.gradle.api.publish.PublishingExtension
import org.gradle.api.publish.maven.MavenPublication
import org.gradle.api.publish.maven.tasks.PublishToMavenRepository
@@ -10,6 +11,7 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.register
import org.gradle.kotlin.dsl.withType
+import org.gradle.plugins.signing.SigningExtension
import org.jetbrains.DokkaPublicationChannel.*
import java.net.URI
@@ -26,9 +28,9 @@ class DokkaPublicationBuilder {
fun Project.registerDokkaArtifactPublication(publicationName: String, configure: DokkaPublicationBuilder.() -> Unit) {
configure<PublishingExtension> {
publications {
- register<MavenPublication>(publicationName) {
+ val publicationProvider = register<MavenPublication>(publicationName) {
val builder = DokkaPublicationBuilder().apply(configure)
- this.artifactId = builder.artifactId
+ artifactId = builder.artifactId
when (builder.component) {
DokkaPublicationBuilder.Component.Java -> from(components["java"])
DokkaPublicationBuilder.Component.Shadow -> run {
@@ -36,9 +38,12 @@ fun Project.registerDokkaArtifactPublication(publicationName: String, configure:
extensions.getByType(ShadowExtension::class.java).component(this)
}
}
+ configurePom("Dokka ${project.name}")
}
+ signPublicationIfKeyPresent(publicationProvider)
}
}
+
configureBintrayPublicationIfNecessary(publicationName)
configureSpacePublicationIfNecessary(publicationName)
createDokkaPublishTaskIfNecessary()
@@ -126,4 +131,45 @@ private fun Project.configureBintrayPublication(vararg publications: String) {
}
+private fun MavenPublication.configurePom(projectName: String) {
+ pom {
+ name.set(projectName)
+ description.set("Dokka is a documentation engine for Kotlin and Java, performing the same function as Javadoc for Java")
+ url.set("https://github.com/Kotlin/dokka")
+
+ licenses {
+ license {
+ name.set("The Apache Software License, Version 2.0")
+ url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
+ distribution.set("repo")
+ }
+ }
+
+ developers {
+ developer {
+ id.set("JetBrains")
+ name.set("JetBrains Team")
+ organization.set("JetBrains")
+ organizationUrl.set("http://www.jetbrains.com")
+ }
+ }
+ scm {
+ connection.set("scm:git:git://github.com/Kotlin/dokka.git")
+ url.set("https://github.com/Kotlin/dokka/tree/master")
+ }
+ }
+}
+
+@Suppress("UnstableApiUsage")
+private fun Project.signPublicationIfKeyPresent(publicationProvider: Provider<MavenPublication>) {
+ val signingKey = System.getenv("SIGN_KEY")
+ val signingKeyPassphrase = System.getenv("SIGN_KEY_PASSPHRASE")
+
+ if (!signingKey.isNullOrBlank()) {
+ extensions.configure<SigningExtension>("signing") {
+ useInMemoryPgpKeys(signingKey, signingKeyPassphrase)
+ sign(publicationProvider.get())
+ }
+ }
+}