diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-14 10:06:04 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-14 11:41:31 +0200 |
commit | 7ff409fdf621932590dbf0118fff2c73dc76b951 (patch) | |
tree | fb120475a8d5ba3860eebaffaca44eb98d0a4bb9 /buildSrc/src/main/kotlin/org/jetbrains | |
parent | 7a8bdee752c25a9cd09f5859b76463bf44c747db (diff) | |
download | dokka-7ff409fdf621932590dbf0118fff2c73dc76b951.tar.gz dokka-7ff409fdf621932590dbf0118fff2c73dc76b951.tar.bz2 dokka-7ff409fdf621932590dbf0118fff2c73dc76b951.zip |
Adapt changes from "Simplify publishing configuration and enable sourcejars"
Diffstat (limited to 'buildSrc/src/main/kotlin/org/jetbrains')
3 files changed, 58 insertions, 63 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt b/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt deleted file mode 100644 index 4180c445..00000000 --- a/buildSrc/src/main/kotlin/org/jetbrains/BintrayPublishing.kt +++ /dev/null @@ -1,29 +0,0 @@ -package org.jetbrains - -import com.jfrog.bintray.gradle.BintrayExtension -import org.gradle.api.Project -import org.gradle.kotlin.dsl.provideDelegate - -fun Project.configureBintrayPublication(vararg publications: String) { - val dokka_version: String by this - val dokka_publication_channel: String by this - extensions.configure<BintrayExtension>("bintray") { - user = System.getenv("BINTRAY_USER") - key = System.getenv("BINTRAY_KEY") - dryRun = System.getenv("BINTRAY_DRY_RUN") == "true" || - project.properties["bintray_dry_run"] == "true" - pkg = PackageConfig().apply { - repo = dokka_publication_channel - name = "dokka" - userOrg = "kotlin" - desc = "Dokka, the Kotlin documentation tool" - vcsUrl = "https://github.com/kotlin/dokka.git" - setLicenses("Apache-2.0") - version = VersionConfig().apply { - name = dokka_version - } - } - setPublications(*publications) - } -} - diff --git a/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt b/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt deleted file mode 100644 index 5dbb8fb9..00000000 --- a/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt +++ /dev/null @@ -1,34 +0,0 @@ -package org.jetbrains - -import com.github.jengelman.gradle.plugins.shadow.ShadowExtension -import org.gradle.api.Project -import org.gradle.api.plugins.JavaPlugin -import org.gradle.api.plugins.JavaPluginExtension -import org.gradle.api.publish.PublishingExtension -import org.gradle.api.publish.maven.MavenPublication -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.get - -fun Project.configurePublication(artifactId: String, useShadow: Boolean = false) { - configure<PublishingExtension> { - publications { - create<MavenPublication>("maven") { - this.artifactId = artifactId - if (useShadow) { - val shadow = extensions.getByType(ShadowExtension::class.java) - shadow.component(this) - } else { - from(components["java"]) - } - } - } - } - configureBintrayPublication("maven") - plugins.all { - if (this is JavaPlugin) { - val extension = extensions.getByType(JavaPluginExtension::class.java) - @Suppress("UnstableApiUsage") extension.withSourcesJar() - } - } -} diff --git a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt new file mode 100644 index 00000000..47fb23f2 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt @@ -0,0 +1,58 @@ +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.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.kotlin.dsl.* + +class DokkaPublicationBuilder { + enum class Component { + Java, Shadow + } + var artifactId: String? = null + var component: Component = Component.Java +} + +fun Project.registerDokkaArtifactPublication(publicationName: String, configure: DokkaPublicationBuilder.() -> Unit) { + configure<PublishingExtension> { + publications { + register<MavenPublication>(publicationName) { + val builder = DokkaPublicationBuilder().apply(configure) + this.artifactId = builder.artifactId + when (builder.component) { + DokkaPublicationBuilder.Component.Java -> from(components["java"]) + DokkaPublicationBuilder.Component.Shadow -> + extensions.getByType(ShadowExtension::class.java).component(this) + } + } + } + } + + configureBintrayPublication(publicationName) +} + +fun Project.configureBintrayPublication(vararg publications: String) { + val dokka_version: String by this + val dokka_publication_channel: String by this + extensions.configure<BintrayExtension>("bintray") { + user = System.getenv("BINTRAY_USER") + key = System.getenv("BINTRAY_KEY") + dryRun = System.getenv("BINTRAY_DRY_RUN") == "true" || + project.properties["bintray_dry_run"] == "true" + pkg = PackageConfig().apply { + repo = dokka_publication_channel + name = "dokka" + userOrg = "kotlin" + desc = "Dokka, the Kotlin documentation tool" + vcsUrl = "https://github.com/kotlin/dokka.git" + setLicenses("Apache-2.0") + version = VersionConfig().apply { + name = dokka_version + } + } + setPublications(*publications) + } +} + |