aboutsummaryrefslogtreecommitdiff
path: root/buildSrc/src
diff options
context:
space:
mode:
authorAurimas Liutikas <aurimas@google.com>2020-07-13 18:33:28 -0700
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-14 11:41:31 +0200
commit7001425367a4db79c6fcdf6b8d0c53508ba50aa7 (patch)
tree8e3d80556de27b9cf1ee93f51e7d46a498a905f6 /buildSrc/src
parentbed2450c8d6ddd5c1ef05e3e451443c286eddea1 (diff)
downloaddokka-7001425367a4db79c6fcdf6b8d0c53508ba50aa7.tar.gz
dokka-7001425367a4db79c6fcdf6b8d0c53508ba50aa7.tar.bz2
dokka-7001425367a4db79c6fcdf6b8d0c53508ba50aa7.zip
Simplify publishing configuration and enable sourcejars
Diffstat (limited to 'buildSrc/src')
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/PublicationConfiguration.kt34
1 files changed, 34 insertions, 0 deletions
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<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()
+ }
+ }
+}