aboutsummaryrefslogtreecommitdiff
path: root/buildSrc
diff options
context:
space:
mode:
Diffstat (limited to 'buildSrc')
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt38
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt2
-rw-r--r--buildSrc/src/main/kotlin/org/jetbrains/publication.kt18
3 files changed, 46 insertions, 12 deletions
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt b/buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt
index 05593b40..059c79ea 100644
--- a/buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt
+++ b/buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt
@@ -1,3 +1,5 @@
+@file:Suppress("LocalVariableName")
+
package org.jetbrains
import org.gradle.api.GradleException
@@ -18,16 +20,40 @@ internal enum class DokkaPublicationChannel {
SpaceDokkaDev -> false
BintrayKotlinDev, BintrayKotlinEap, BintrayKotlinDokka -> true
}
-}
-internal val Project.publicationChannel: DokkaPublicationChannel
- get() {
- val dokka_publication_channel: String by this
- return when (dokka_publication_channel) {
+ companion object {
+ fun fromPropertyString(value: String): DokkaPublicationChannel = when (value) {
"space-dokka-dev" -> SpaceDokkaDev
"bintray-kotlin-dev" -> BintrayKotlinDev
"bintray-kotlin-eap" -> BintrayKotlinEap
"bintray-kotlin-dokka" -> BintrayKotlinDokka
- else -> throw GradleException("Unknown dokka_publication_channel=$dokka_publication_channel")
+ else -> throw IllegalArgumentException("Unknown dokka_publication_channel=$value")
+ }
+ }
+}
+
+internal val Project.publicationChannels: Set<DokkaPublicationChannel>
+ get() {
+ val publicationChannel = this.properties["dokka_publication_channel"]?.toString()
+ val publicationChannels = this.properties["dokka_publication_channels"]?.toString()
+ if (publicationChannel != null && publicationChannels != null) {
+ throw IllegalArgumentException(
+ "Only one of dokka_publication_channel and dokka_publication_channel*s* can be set. Found: \n" +
+ "dokka_publication_channel=$publicationChannel\n" +
+ "dokka_publication_channels=$publicationChannels"
+ )
+ }
+
+ if (publicationChannel != null) {
+ return setOf(DokkaPublicationChannel.fromPropertyString(publicationChannel))
}
+
+ if (publicationChannels != null) {
+ return publicationChannels.split("&").map { channel ->
+ DokkaPublicationChannel.fromPropertyString(channel)
+ }.toSet()
+ }
+
+ return emptySet()
}
+
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt b/buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt
index 317e5152..4659f669 100644
--- a/buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt
+++ b/buildSrc/src/main/kotlin/org/jetbrains/ValidatePublications.kt
@@ -32,7 +32,7 @@ open class ValidatePublications : DefaultTask() {
.filterIsInstance<MavenPublication>()
.filter { it.version == project.dokkaVersion }
.forEach { publication ->
- if (project.publicationChannel.isBintrayRepository) {
+ if (project.publicationChannels.any { it.isBintrayRepository }) {
checkPublicationIsConfiguredForBintray(subProject, publication)
}
checkProjectDependenciesArePublished(subProject)
diff --git a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
index b4259978..291e3f15 100644
--- a/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
+++ b/buildSrc/src/main/kotlin/org/jetbrains/publication.kt
@@ -42,7 +42,7 @@ fun Project.registerDokkaArtifactPublication(publicationName: String, configure:
}
fun Project.configureSpacePublicationIfNecessary(vararg publications: String) {
- if (publicationChannel.isSpaceRepository) {
+ if (SpaceDokkaDev in this.publicationChannels) {
configure<PublishingExtension> {
repositories {
/* already registered */
@@ -73,17 +73,17 @@ fun Project.configureSpacePublicationIfNecessary(vararg publications: String) {
fun Project.createDokkaPublishTaskIfNecessary() {
tasks.maybeCreate("dokkaPublish").run {
- if (publicationChannel.isSpaceRepository) {
+ if (publicationChannels.any { it.isSpaceRepository }) {
dependsOn(tasks.named("publish"))
}
- if (publicationChannel.isBintrayRepository) {
+ if (publicationChannels.any { it.isBintrayRepository }) {
dependsOn(tasks.named("bintrayUpload"))
}
}
}
fun Project.configureBintrayPublicationIfNecessary(vararg publications: String) {
- if (publicationChannel.isBintrayRepository) {
+ if (publicationChannels.any { it.isBintrayRepository }) {
configureBintrayPublication(*publications)
}
}
@@ -95,12 +95,20 @@ private fun Project.configureBintrayPublication(vararg publications: String) {
dryRun = System.getenv("BINTRAY_DRY_RUN") == "true" ||
project.properties["bintray_dry_run"] == "true"
pkg = PackageConfig().apply {
- repo = when (publicationChannel) {
+ val bintrayPublicationChannels = publicationChannels.filter { it.isBintrayRepository }
+ if (bintrayPublicationChannels.size > 1) {
+ throw IllegalArgumentException(
+ "Only a single bintray repository can be used for publishing at once. Found $publicationChannels"
+ )
+ }
+
+ repo = when (bintrayPublicationChannels.single()) {
SpaceDokkaDev -> throw IllegalStateException("$SpaceDokkaDev is not a bintray repository")
BintrayKotlinDev -> "kotlin-dev"
BintrayKotlinEap -> "kotlin-eap"
BintrayKotlinDokka -> "dokka"
}
+
name = "dokka"
userOrg = "kotlin"
desc = "Dokka, the Kotlin documentation tool"