diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-06-05 15:12:59 +0200 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-06-05 15:12:59 +0200 |
commit | 5aace9a4633f95a45f9ffd7f1cf8e833e573e489 (patch) | |
tree | 8690d266f28ebcba528028da6932bc9a5747c72c /runners/gradle-plugin/src/main/kotlin | |
parent | 7a4aa33a03381a21049c7447f2f70f6959664302 (diff) | |
download | dokka-5aace9a4633f95a45f9ffd7f1cf8e833e573e489.tar.gz dokka-5aace9a4633f95a45f9ffd7f1cf8e833e573e489.tar.bz2 dokka-5aace9a4633f95a45f9ffd7f1cf8e833e573e489.zip |
Bugfix for duplicate source roots
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt | 4 | ||||
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 41 |
2 files changed, 24 insertions, 21 deletions
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<GradlePassConfigurationImpl> @Suppress("UNCHECKED_CAST") get() = DslObject(this).extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl> @@ -186,8 +183,8 @@ open class DokkaTask : DefaultTask() { private fun collectFromMultiPlatform(): List<GradlePassConfigurationImpl> { 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<GradlePassConfigurationImpl>, - autoConfigurations: List<ConfigurationExtractor.PlatformData>) = - userConfigurations.map { userConfig -> - val autoConfig = autoConfigurations.find { autoConfig -> autoConfig.name == userConfig.name } - if (autoConfig != null) mergeUserConfigurationAndPlatformData(userConfig, autoConfig) else userConfig - } - + autoConfigurations: List<ConfigurationExtractor.PlatformData>): List<GradlePassConfigurationImpl> { + val merged: MutableList<GradlePassConfigurationImpl> = 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()){ |