diff options
Diffstat (limited to 'buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt')
-rw-r--r-- | buildSrc/src/main/kotlin/org/jetbrains/DokkaPublicationChannel.kt | 38 |
1 files changed, 32 insertions, 6 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() } + |