aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/main/kotlin/org
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-07-01 12:50:22 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-07-01 12:50:22 +0200
commitf55d000ac5f7609a6cc8472e315ae45d4cbcc77b (patch)
tree69748545fd1a2ed2ddfcc9b4ea87a60d7355ef39 /runners/gradle-plugin/src/main/kotlin/org
parent04df5c458239fb1966768af85de4d105a3c43233 (diff)
downloaddokka-f55d000ac5f7609a6cc8472e315ae45d4cbcc77b.tar.gz
dokka-f55d000ac5f7609a6cc8472e315ae45d4cbcc77b.tar.bz2
dokka-f55d000ac5f7609a6cc8472e315ae45d4cbcc77b.zip
Fix bug with nonexistent file on native
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/org')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt46
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt6
2 files changed, 27 insertions, 25 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 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<Task>, project: Project): PlatformData? {
@@ -84,9 +79,9 @@ object ConfigurationExtractor {
}
val taskClasspath: Iterable<File> =
- (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<File> =
- getMainCompilation(target).allKotlinSourceSets.flatMap { it.kotlin.sourceDirectories }
-
- private fun getClasspath(target: KotlinTarget): List<File> =
- getMainCompilation(target).compileDependencyFiles.files.toList()
-
- private fun getMainCompilation(target: KotlinTarget): KotlinCompilation<KotlinCommonOptions> =
- 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<File> = getMainCompilation(target)
+ ?.allKotlinSourceSets
+ ?.flatMap { it.kotlin.sourceDirectories }
+ ?.filter { it.exists() }
+ .orEmpty()
+
+ private fun getClasspath(target: KotlinTarget?): List<File> = getMainCompilation(target)
+ ?.compileDependencyFiles
+ ?.files
+ ?.toList()
+ ?.filter { it.exists() }
+ .orEmpty()
+
+ private fun getMainCompilation(target: KotlinTarget?): KotlinCompilation<KotlinCommonOptions>? =
+ 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<File>,
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<GradlePassConfigurationImpl> {