From e99be615ce7c2c2b5c3ee5e3f8941c41c1e7a944 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 31 Jan 2020 00:37:29 +0100 Subject: Bump Gradle version, migrate to Kotlin DSL, refactor publishing --- plugins/xml/build.gradle.kts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 plugins/xml/build.gradle.kts (limited to 'plugins/xml/build.gradle.kts') diff --git a/plugins/xml/build.gradle.kts b/plugins/xml/build.gradle.kts new file mode 100644 index 00000000..cd65cfe4 --- /dev/null +++ b/plugins/xml/build.gradle.kts @@ -0,0 +1,8 @@ +publishing { + publications { + register("xmlPlugin") { + artifactId = "xml-plugin" + from(components["java"]) + } + } +} \ No newline at end of file -- cgit From 7001425367a4db79c6fcdf6b8d0c53508ba50aa7 Mon Sep 17 00:00:00 2001 From: Aurimas Liutikas Date: Mon, 13 Jul 2020 18:33:28 -0700 Subject: Simplify publishing configuration and enable sourcejars --- .../org/jetbrains/PublicationConfiguration.kt | 34 ++++++++++++++++++++++ core/build.gradle.kts | 19 ++---------- core/dependencies/build.gradle.kts | 13 ++------- kotlin-analysis/build.gradle.kts | 13 ++------- kotlin-analysis/dependencies/build.gradle.kts | 15 ++-------- plugins/base/build.gradle.kts | 13 ++------- plugins/gfm/build.gradle.kts | 15 ++-------- plugins/javadoc/build.gradle.kts | 13 ++------- plugins/jekyll/build.gradle.kts | 15 ++-------- plugins/kotlin-as-java/build.gradle.kts | 13 ++------- plugins/mathjax/build.gradle.kts | 13 ++------- plugins/xml/build.gradle.kts | 11 ++----- runners/cli/build.gradle.kts | 13 ++------- runners/maven-plugin/build.gradle.kts | 15 ++-------- testApi/build.gradle.kts | 19 ++---------- 15 files changed, 65 insertions(+), 169 deletions(-) create mode 100644 buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt (limited to 'plugins/xml/build.gradle.kts') diff --git a/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt b/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt new file mode 100644 index 00000000..5dbb8fb9 --- /dev/null +++ b/buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt @@ -0,0 +1,34 @@ +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 { + publications { + create("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/core/build.gradle.kts b/core/build.gradle.kts index 45ddccf3..030db5c6 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { `maven-publish` @@ -16,11 +16,6 @@ dependencies { testImplementation(kotlin("test-junit")) } -val sourceJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) -} - tasks { processResources { val dokka_version: String by project @@ -34,14 +29,4 @@ tasks { } } -publishing { - publications { - register("dokkaCore") { - artifactId = "dokka-core" - from(components["java"]) - artifact(sourceJar.get()) - } - } -} - -configureBintrayPublication("dokkaCore") +configurePublication("dokka-core") diff --git a/core/dependencies/build.gradle.kts b/core/dependencies/build.gradle.kts index a26d109e..082861b6 100644 --- a/core/dependencies/build.gradle.kts +++ b/core/dependencies/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { id("com.github.johnrengelman.shadow") @@ -28,13 +28,4 @@ tasks { } } -publishing { - publications { - register("dokkaCoreDependencies") { - artifactId = "dokka-core-dependencies" - project.shadow.component(this) - } - } -} - -configureBintrayPublication("dokkaCoreDependencies") +configurePublication("dokka-core-dependencies", useShadow = true) diff --git a/kotlin-analysis/build.gradle.kts b/kotlin-analysis/build.gradle.kts index 67480f82..5acc1f06 100644 --- a/kotlin-analysis/build.gradle.kts +++ b/kotlin-analysis/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { id("com.github.johnrengelman.shadow") @@ -15,13 +15,4 @@ dependencies { api(project(":kotlin-analysis:dependencies", configuration = "shadow")) } -publishing { - publications { - register("analysis") { - artifactId = "dokka-analysis" - from(components["java"]) - } - } -} - -configureBintrayPublication("analysis") +configurePublication("dokka-analysis") diff --git a/kotlin-analysis/dependencies/build.gradle.kts b/kotlin-analysis/dependencies/build.gradle.kts index 5bba6422..1fd13630 100644 --- a/kotlin-analysis/dependencies/build.gradle.kts +++ b/kotlin-analysis/dependencies/build.gradle.kts @@ -1,5 +1,4 @@ -import org.jetbrains.configureBintrayPublication - +import org.jetbrains.configurePublication plugins { id("com.github.johnrengelman.shadow") @@ -54,14 +53,4 @@ tasks { } } - -publishing { - publications { - register("kotlin-analysis-dependencies") { - artifactId = "kotlin-analysis-dependencies" - project.shadow.component(this) - } - } -} - -configureBintrayPublication("kotlin-analysis-dependencies") +configurePublication("kotlin-analysis-dependencies", useShadow = true) diff --git a/plugins/base/build.gradle.kts b/plugins/base/build.gradle.kts index 1fe3dbc2..61e2ef01 100644 --- a/plugins/base/build.gradle.kts +++ b/plugins/base/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { id("com.jfrog.bintray") @@ -30,13 +30,4 @@ tasks { } } -publishing { - publications { - register("basePlugin") { - artifactId = "dokka-base" - from(components["java"]) - } - } -} - -configureBintrayPublication("basePlugin") +configurePublication("dokka-base") diff --git a/plugins/gfm/build.gradle.kts b/plugins/gfm/build.gradle.kts index fac2c1c0..73958046 100644 --- a/plugins/gfm/build.gradle.kts +++ b/plugins/gfm/build.gradle.kts @@ -1,18 +1,9 @@ -import org.jetbrains.configureBintrayPublication - -publishing { - publications { - register("gfmPlugin") { - artifactId = "gfm-plugin" - from(components["java"]) - } - } -} - -configureBintrayPublication("gfmPlugin") +import org.jetbrains.configurePublication dependencies { implementation(project(":plugins:base")) testImplementation(project(":plugins:base")) testImplementation(project(":plugins:base:test-utils")) } + +configurePublication("gfm-plugin") diff --git a/plugins/javadoc/build.gradle.kts b/plugins/javadoc/build.gradle.kts index ebf79f8f..5846ee62 100644 --- a/plugins/javadoc/build.gradle.kts +++ b/plugins/javadoc/build.gradle.kts @@ -1,13 +1,4 @@ -import org.jetbrains.configureBintrayPublication - -publishing { - publications { - register("javadocPlugin") { - artifactId = "javadoc-plugin" - from(components["java"]) - } - } -} +import org.jetbrains.configurePublication dependencies { implementation("com.soywiz.korlibs.korte:korte-jvm:1.10.3") @@ -19,4 +10,4 @@ dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutines_version") } -configureBintrayPublication("javadocPlugin") +configurePublication("javadoc-plugin") diff --git a/plugins/jekyll/build.gradle.kts b/plugins/jekyll/build.gradle.kts index 90002466..0d1e38d6 100644 --- a/plugins/jekyll/build.gradle.kts +++ b/plugins/jekyll/build.gradle.kts @@ -1,17 +1,8 @@ -import org.jetbrains.configureBintrayPublication - -publishing { - publications { - register("jekyllPlugin") { - artifactId = "jekyll-plugin" - from(components["java"]) - } - } -} - -configureBintrayPublication("jekyllPlugin") +import org.jetbrains.configurePublication dependencies { implementation(project(":plugins:base")) implementation(project(":plugins:gfm")) } + +configurePublication("jekyll-plugin") diff --git a/plugins/kotlin-as-java/build.gradle.kts b/plugins/kotlin-as-java/build.gradle.kts index bd08ab92..27e90f84 100644 --- a/plugins/kotlin-as-java/build.gradle.kts +++ b/plugins/kotlin-as-java/build.gradle.kts @@ -1,13 +1,4 @@ -import org.jetbrains.configureBintrayPublication - -publishing { - publications { - register("kotlinAsJavaPlugin") { - artifactId = "kotlin-as-java-plugin" - from(components["java"]) - } - } -} +import org.jetbrains.configurePublication dependencies { implementation(project(":plugins:base")) @@ -16,4 +7,4 @@ dependencies { testImplementation(project(":test-tools")) } -configureBintrayPublication("kotlinAsJavaPlugin") \ No newline at end of file +configurePublication("kotlin-as-java-plugin") diff --git a/plugins/mathjax/build.gradle.kts b/plugins/mathjax/build.gradle.kts index 67f4822f..ea4cdff0 100644 --- a/plugins/mathjax/build.gradle.kts +++ b/plugins/mathjax/build.gradle.kts @@ -1,12 +1,3 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication -publishing { - publications { - register("mathjaxPlugin") { - artifactId = "mathjax-plugin" - from(components["java"]) - } - } -} - -configureBintrayPublication("mathjaxPlugin") +configurePublication("mathjax-plugin") diff --git a/plugins/xml/build.gradle.kts b/plugins/xml/build.gradle.kts index cd65cfe4..5d3984bc 100644 --- a/plugins/xml/build.gradle.kts +++ b/plugins/xml/build.gradle.kts @@ -1,8 +1,3 @@ -publishing { - publications { - register("xmlPlugin") { - artifactId = "xml-plugin" - from(components["java"]) - } - } -} \ No newline at end of file +import org.jetbrains.configurePublication + +configurePublication("xml-plugin") \ No newline at end of file diff --git a/runners/cli/build.gradle.kts b/runners/cli/build.gradle.kts index 00e459b2..19a49346 100644 --- a/runners/cli/build.gradle.kts +++ b/runners/cli/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { id("com.github.johnrengelman.shadow") @@ -15,7 +15,6 @@ dependencies { implementation(kotlin("stdlib")) } - tasks { shadowJar { val dokka_version: String by project @@ -27,13 +26,5 @@ tasks { } } -publishing { - publications { - register("dokkaCli") { - artifactId = "dokka-cli" - project.shadow.component(this) - } - } -} +configurePublication("dokka-cli", useShadow = true) -configureBintrayPublication("dokkaCli") diff --git a/runners/maven-plugin/build.gradle.kts b/runners/maven-plugin/build.gradle.kts index 6214da6d..83d9f5af 100644 --- a/runners/maven-plugin/build.gradle.kts +++ b/runners/maven-plugin/build.gradle.kts @@ -1,7 +1,6 @@ -import org.jetbrains.configureBintrayPublication import org.jetbrains.CrossPlatformExec import org.jetbrains.SetupMaven - +import org.jetbrains.configurePublication val setupMaven by tasks.register("setupMaven") @@ -91,14 +90,4 @@ tasks.named("jar") { } } -publishing { - publications { - register("dokkaMavenPlugin") { - artifactId = "dokka-maven-plugin" - from(components["java"]) - artifact(sourceJar.get()) - } - } -} - -configureBintrayPublication("dokkaMavenPlugin") +configurePublication("dokka-maven-plugin") diff --git a/testApi/build.gradle.kts b/testApi/build.gradle.kts index c8b510a1..1576dd99 100644 --- a/testApi/build.gradle.kts +++ b/testApi/build.gradle.kts @@ -1,4 +1,4 @@ -import org.jetbrains.configureBintrayPublication +import org.jetbrains.configurePublication plugins { `maven-publish` @@ -13,19 +13,4 @@ dependencies { implementation(kotlin("reflect")) } -val sourceJar by tasks.registering(Jar::class) { - archiveClassifier.set("sources") - from(sourceSets["main"].allSource) -} - -publishing { - publications { - register("dokkaTestAPI") { - artifactId = "dokka-test-api" - from(components["java"]) - artifact(sourceJar.get()) - } - } -} - -configureBintrayPublication("dokkaTestAPI") \ No newline at end of file +configurePublication("dokka-test-api") -- cgit