Configurable updater fix

This commit is contained in:
Alexander Nozik 2019-05-10 19:53:54 +03:00
parent 1344471f40
commit fdd5b11370
2 changed files with 25 additions and 24 deletions

View File

@ -1,15 +1,15 @@
import org.jetbrains.dokka.gradle.DokkaTask import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformJvmPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
plugins { plugins {
id("org.jetbrains.dokka") id("org.jetbrains.dokka")
`maven-publish` `maven-publish`
} }
plugins.withType(KotlinMultiplatformPlugin::class){ afterEvaluate {
configure<KotlinMultiplatformExtension>{
extensions.findByType<KotlinMultiplatformExtension>()?.apply{
val dokka by tasks.getting(DokkaTask::class) { val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html" outputFormat = "html"
outputDirectory = "$buildDir/javadoc" outputDirectory = "$buildDir/javadoc"
@ -33,42 +33,43 @@ plugins.withType(KotlinMultiplatformPlugin::class){
} }
} }
val javadocJar by tasks.registering(Jar::class) { val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka) dependsOn(dokka)
archiveClassifier.set("javadoc") archiveClassifier.set("javadoc")
from("$buildDir/javadoc") from("$buildDir/javadoc")
} }
configure<PublishingExtension>{ configure<PublishingExtension> {
targets.all { targets.all {
val publication = publications.findByName(name) as MavenPublication val publication = publications.findByName(name) as MavenPublication
// Patch publications with fake javadoc // Patch publications with fake javadoc
publication.artifact(javadocJar.get()) publication.artifact(kdocJar.get())
} }
} }
} }
}
plugins.withType(KotlinPlatformJvmPlugin::class){
extensions.findByType<KotlinJvmProjectExtension>()?.apply{
val dokka by tasks.getting(DokkaTask::class) { val dokka by tasks.getting(DokkaTask::class) {
outputFormat = "html" outputFormat = "html"
outputDirectory = "$buildDir/javadoc" outputDirectory = "$buildDir/javadoc"
jdkVersion = 8 jdkVersion = 8
} }
val javadocJar by tasks.registering(Jar::class) { val kdocJar by tasks.registering(Jar::class) {
group = JavaBasePlugin.DOCUMENTATION_GROUP group = JavaBasePlugin.DOCUMENTATION_GROUP
dependsOn(dokka) dependsOn(dokka)
archiveClassifier.set("javadoc") archiveClassifier.set("javadoc")
from("$buildDir/javadoc") from("$buildDir/javadoc")
} }
configure<PublishingExtension>{ configure<PublishingExtension> {
publications.filterIsInstance<MavenPublication>().forEach {publication -> publications.filterIsInstance<MavenPublication>().forEach { publication ->
publication.artifact(javadocJar.get()) publication.artifact(kdocJar.get())
}
} }
} }
} }

View File

@ -41,6 +41,6 @@ interface Configurable {
fun <T : Configurable> T.configure(meta: Meta): T = this.apply { config.update(meta) } fun <T : Configurable> T.configure(meta: Meta): T = this.apply { config.update(meta) }
fun <T : Configurable> T.configure(action: Config.() -> Unit): T = this.apply { config.apply(action) } fun <T : Configurable> T.configure(action: MetaBuilder.() -> Unit): T = configure(buildMeta(action))
open class SimpleConfigurable(override val config: Config) : Configurable open class SimpleConfigurable(override val config: Config) : Configurable