From 5aace9a4633f95a45f9ffd7f1cf8e833e573e489 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 5 Jun 2019 15:12:59 +0200 Subject: Bugfix for duplicate source roots --- .../dokka/gradle/ConfigurationExtractor.kt | 4 +-- .../kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 41 ++++++++++++---------- 2 files changed, 24 insertions(+), 21 deletions(-) (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt index 185a32fd..583d352a 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt @@ -59,9 +59,9 @@ object ConfigurationExtractor { val platformTargets = targets.filter { it.platformType != KotlinPlatformType.common } val config = platformTargets.map { - PlatformData(it.name, getClasspath(it) + commonTargetClasspath.orEmpty(), - getSourceSet(it) + commonTargetSourceList.orEmpty(), it.platformType.toString()) + PlatformData(it.name, getClasspath(it), getSourceSet(it), it.platformType.toString()) } + return config + PlatformData("common", commonTargetClasspath.orEmpty(), commonTargetSourceList.orEmpty(), "common") } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index 554748b9..62a37249 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -67,9 +67,6 @@ open class DokkaTask : DefaultTask() { @Input var cacheRoot: String? = null - @Input - var collectInheritedExtensionsFromLibraries: Boolean = false - var multiplatform: NamedDomainObjectContainer @Suppress("UNCHECKED_CAST") get() = DslObject(this).extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as NamedDomainObjectContainer @@ -186,8 +183,8 @@ open class DokkaTask : DefaultTask() { private fun collectFromMultiPlatform(): List { val baseConfig = mergeUserAndAutoConfigurations( - multiplatform.toList(), - ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty() + multiplatform.toList(), + ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty() ) return if (subProjects.isEmpty()) baseConfig @@ -229,20 +226,27 @@ open class DokkaTask : DefaultTask() { } private fun mergeUserAndAutoConfigurations(userConfigurations: List, - autoConfigurations: List) = - userConfigurations.map { userConfig -> - val autoConfig = autoConfigurations.find { autoConfig -> autoConfig.name == userConfig.name } - if (autoConfig != null) mergeUserConfigurationAndPlatformData(userConfig, autoConfig) else userConfig - } - + autoConfigurations: List): List { + val merged: MutableList = mutableListOf() + merged.addAll( + userConfigurations.map { userConfig -> + val autoConfig = autoConfigurations.find { autoConfig -> autoConfig.name == userConfig.name } + if (autoConfig != null) mergeUserConfigurationAndPlatformData(userConfig, autoConfig) else userConfig + } + ) + return merged.toList() + } - private fun mergeUserConfigurationAndPlatformData(user: GradlePassConfigurationImpl, - auto: ConfigurationExtractor.PlatformData): GradlePassConfigurationImpl { - user.sourceRoots.addAll(auto.sourceRoots.toSourceRoots()) - user.classpath += auto.classpath.map { it.absolutePath } - if (user.platform == null) - user.platform = auto.platform - return user + private fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, + autoConfig: ConfigurationExtractor.PlatformData): GradlePassConfigurationImpl { + val merged = GradlePassConfigurationImpl(userConfig.name) + merged.apply { + sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct()) + classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct() + if (userConfig.platform == null) + platform = autoConfig.platform + } + return merged } private fun defaultPassConfiguration(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { @@ -251,7 +255,6 @@ open class DokkaTask : DefaultTask() { } config.samples = config.samples.map { project.file(it).absolutePath } config.includes = config.includes.map { project.file(it).absolutePath } - config.collectInheritedExtensionsFromLibraries = collectInheritedExtensionsFromLibraries config.suppressedFiles += collectSuppressedFiles(config.sourceRoots) config.externalDocumentationLinks.addAll(externalDocumentationLinks) if (config.platform != null && config.platform.toString().isNotEmpty()){ -- cgit