From f55d000ac5f7609a6cc8472e315ae45d4cbcc77b Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Mon, 1 Jul 2019 12:50:22 +0200 Subject: Fix bug with nonexistent file on native --- .../dokka/gradle/ConfigurationExtractor.kt | 46 +++++++++++----------- .../kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 6 +-- 2 files changed, 27 insertions(+), 25 deletions(-) (limited to 'runners/gradle-plugin/src/main') 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 13cda6f3..491aaae0 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 @@ -53,17 +53,12 @@ object ConfigurationExtractor { } val commonTarget = targets.find { it.platformType == KotlinPlatformType.common } - val commonTargetCompilation = commonTarget?.compilations?.getByName("main") - val commonTargetSourceList = commonTargetCompilation?.allKotlinSourceSets?.flatMap { it.kotlin.sourceDirectories } - val commonTargetClasspath = commonTargetCompilation?.compileDependencyFiles?.files?.toList() - val platformTargets = targets.filter { it.platformType != KotlinPlatformType.common } - val config = platformTargets.map { PlatformData(it.name, getClasspath(it), getSourceSet(it), it.platformType.toString()) } - return config + PlatformData("common", commonTargetClasspath.orEmpty(), commonTargetSourceList.orEmpty(), "common") + return config + PlatformData("common", getSourceSet(commonTarget), getClasspath(commonTarget), "common") } fun extractFromKotlinTasks(kotlinTasks: List, project: Project): PlatformData? { @@ -84,9 +79,9 @@ object ConfigurationExtractor { } val taskClasspath: Iterable = - (it["getClasspath", AbstractCompile::class].takeIfIsFunc()?.invoke() - ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v() - ?: it["getClasspath", abstractKotlinCompileClz]()) + (it["getClasspath", AbstractCompile::class].takeIfIsFunc()?.invoke() + ?: it["compileClasspath", abstractKotlinCompileClz].takeIfIsProp()?.v() + ?: it["getClasspath", abstractKotlinCompileClz]()) if (taskClasspath is FileCollection) { allClasspathFileCollection += taskClasspath @@ -107,21 +102,28 @@ object ConfigurationExtractor { } fun extractFromJavaPlugin(project: Project): PlatformData? = - project.convention.findPlugin(JavaPluginConvention::class.java) - ?.run { sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME)?.allSource?.srcDirs } - ?.let { PlatformData(null, emptyList(), it.toList(), "") } - - private fun getSourceSet(target: KotlinTarget): List = - getMainCompilation(target).allKotlinSourceSets.flatMap { it.kotlin.sourceDirectories } - - private fun getClasspath(target: KotlinTarget): List = - getMainCompilation(target).compileDependencyFiles.files.toList() - - private fun getMainCompilation(target: KotlinTarget): KotlinCompilation = - target.compilations.getByName("main") + project.convention.findPlugin(JavaPluginConvention::class.java) + ?.run { sourceSets.findByName(SourceSet.MAIN_SOURCE_SET_NAME)?.allSource?.srcDirs } + ?.let { PlatformData(null, emptyList(), it.toList(), "") } + + private fun getSourceSet(target: KotlinTarget?): List = getMainCompilation(target) + ?.allKotlinSourceSets + ?.flatMap { it.kotlin.sourceDirectories } + ?.filter { it.exists() } + .orEmpty() + + private fun getClasspath(target: KotlinTarget?): List = getMainCompilation(target) + ?.compileDependencyFiles + ?.files + ?.toList() + ?.filter { it.exists() } + .orEmpty() + + private fun getMainCompilation(target: KotlinTarget?): KotlinCompilation? = + target?.compilations?.getByName("main") private fun getPlatformName(platform: KotlinPlatformType): String = - if (platform == KotlinPlatformType.androidJvm) "jvm" else platform.toString() + if (platform == KotlinPlatformType.androidJvm) "jvm" else platform.toString() data class PlatformData(val name: String?, val classpath: List, 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 f985c70a..6e36fb68 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 @@ -187,11 +187,11 @@ open class DokkaTask : DefaultTask() { multiplatform.toList(), ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty() ) - return if (subProjects.isEmpty()) - baseConfig - else + return if (subProjects.isNotEmpty()) subProjects.toProjects().fold(baseConfig, { list, project -> mergeUserAndAutoConfigurations(list, ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty())}) + else + baseConfig } private fun collectFromSinglePlatform(): List { -- cgit