diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-06-12 09:51:31 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-06-15 13:15:30 +0200 |
commit | 0ff8ebe97f540fff0d6fac962749f73b1db689ef (patch) | |
tree | 6f249cae6c17e6d6098b33ce6d177a230396f2ac /runners/gradle-plugin/src/main/kotlin | |
parent | f3baf10b4c882230d382bfcdd94163d070bd0e25 (diff) | |
download | dokka-0ff8ebe97f540fff0d6fac962749f73b1db689ef.tar.gz dokka-0ff8ebe97f540fff0d6fac962749f73b1db689ef.tar.bz2 dokka-0ff8ebe97f540fff0d6fac962749f73b1db689ef.zip |
Change sourceSet collection from List to Set
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt | 21 | ||||
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 21 |
2 files changed, 23 insertions, 19 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 44a0635f..3bd0b6ab 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 @@ -24,15 +24,20 @@ class ConfigurationExtractor(private val project: Project) { val projectExtension = project.extensions.getByType(KotlinProjectExtension::class.java) val sourceSet = projectExtension.sourceSets.findByName(sourceSetName) ?: run { project.logger.error("No source set with name '$sourceSetName' found"); return null } - val compilation = when (projectExtension) { - is KotlinMultiplatformExtension -> { - val targets = projectExtension.targets.flatMap { it.compilations } - targets.find { it.name == sourceSetName } ?: targets.find { it.kotlinSourceSets.contains(sourceSet) } - } - is KotlinSingleTargetExtension -> projectExtension.target.compilations.find { - it.kotlinSourceSets.contains(sourceSet) + val compilation = try { + when (projectExtension) { + is KotlinMultiplatformExtension -> { + val targets = projectExtension.targets.flatMap { it.compilations } + targets.find { it.name == sourceSetName } + ?: targets.find { it.kotlinSourceSets.contains(sourceSet) } + } + is KotlinSingleTargetExtension -> projectExtension.target.compilations.find { + it.kotlinSourceSets.contains(sourceSet) + } + else -> null } - else -> null + } catch (e: NoClassDefFoundError) { // Old Kotlin plugin versions + null } val sourceRoots = sourceSet.sourceFiles 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 5a420d4d..82cba6c1 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 @@ -73,11 +73,10 @@ open class DokkaTask : DefaultTask(), Configurable { internal set(value) = DslObject(this).extensions.add(SOURCE_SETS_EXTENSION_NAME, value) private val kotlinTasks: List<Task> by lazy { - extractKotlinCompileTasks({ - dokkaSourceSets.map { + extractKotlinCompileTasks( + dokkaSourceSets.mapNotNull { it.collectKotlinTasks?.invoke() - } - }.takeIf { it().isNotEmpty() } ?: { defaultKotlinTasks() } + }.takeIf { it.isNotEmpty() }?.flatten() ?: defaultKotlinTasks() ) } @@ -100,8 +99,8 @@ open class DokkaTask : DefaultTask(), Configurable { } } - protected fun extractKotlinCompileTasks(collectTasks: () -> List<Any?>?): List<Task> { - val inputList = (collectTasks.invoke() ?: emptyList()).filterNotNull() + protected fun extractKotlinCompileTasks(collectTasks: List<Any?>?): List<Task> { + val inputList = (collectTasks ?: emptyList()).filterNotNull() val (paths, other) = inputList.partition { it is String } val tasksByPath = paths.map { @@ -145,6 +144,7 @@ open class DokkaTask : DefaultTask(), Configurable { outputDiagnosticInfo = true val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false" System.setProperty(COLORS_ENABLED_PROPERTY, "false") + configuration.passesConfigurations.flatMap { it.sourceRoots }.also(::println) try { loadCore() @@ -211,7 +211,7 @@ open class DokkaTask : DefaultTask(), Configurable { val userConfig = config .apply { collectKotlinTasks?.let { - configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it)) + configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it())) .fold(this) { config, platformData -> mergeUserConfigurationAndPlatformData(config, platformData) } @@ -286,7 +286,7 @@ open class DokkaTask : DefaultTask(), Configurable { if (config.sourceSetID.isBlank()) { config.sourceSetID = config.name.takeIf(String::isNotBlank) ?: config.analysisPlatform.key } - config.displayName = config.sourceSetID.substringBeforeLast("Main") + config.displayName = config.moduleName + config.sourceSetID.substringBeforeLast("Main") config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct() // Workaround for Groovy's GStringImpl config.sourceRoots = config.sourceRoots.distinct().toMutableList() @@ -321,9 +321,8 @@ open class DokkaTask : DefaultTask(), Configurable { // Needed for Gradle incremental build @InputFiles - fun getInputFiles(): FileCollection { - val config = passConfigurations - return project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + + fun getInputFiles(): FileCollection = passConfigurations.let { config -> + project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + project.files(config.flatMap { it.includes }) + project.files(config.flatMap { it.samples }.map { project.fileTree(File(it)) }) } |