diff options
author | sebastian.sellmair <sebastian.sellmair@jetbrains.com> | 2020-07-14 12:14:51 +0200 |
---|---|---|
committer | Sebastian Sellmair <34319766+sellmair@users.noreply.github.com> | 2020-07-14 14:27:46 +0200 |
commit | 62e208137f8058e075d1d38a5b167c8241871ce0 (patch) | |
tree | dd98806c55e0dee7d666f1a52a7943cd8d7fe9b1 /runners/gradle-plugin/src | |
parent | 3428e347fb930cf02acbb6c52aaf98385709f7ac (diff) | |
download | dokka-62e208137f8058e075d1d38a5b167c8241871ce0.tar.gz dokka-62e208137f8058e075d1d38a5b167c8241871ce0.tar.bz2 dokka-62e208137f8058e075d1d38a5b167c8241871ce0.zip |
DokkaMultimoduleTask: Automatically declare dependencies to sub dokka tasks
Diffstat (limited to 'runners/gradle-plugin/src')
3 files changed, 25 insertions, 14 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt index 0270dbe2..38da9631 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt @@ -16,7 +16,7 @@ open class DokkaCollectorTask : DefaultTask() { private lateinit var configuration: GradleDokkaConfigurationImpl @Input - val dokkaTaskNames: MutableSet<String> = mutableSetOf() + var dokkaTaskNames: Set<String> = setOf() @TaskAction fun collect() { diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt index affab485..cc7b8d86 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt @@ -12,7 +12,12 @@ open class DokkaMultimoduleTask : AbstractDokkaTask(), Configurable { @Input - val dokkaTaskNames: MutableSet<String> = mutableSetOf() + var dokkaTaskNames: Set<String> = setOf() + set(value) { + field = value.toSet() + setDependsOn(getSubprojectDokkaTasks(value)) + } + override fun generate() { val bootstrap = DokkaBootstrap("org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl") @@ -36,16 +41,22 @@ open class DokkaMultimoduleTask : AbstractDokkaTask(), Configurable { outputDir = project.file(outputDirectory).absolutePath pluginsClasspath = plugins.resolve().toList() pluginsConfiguration = this@DokkaMultimoduleTask.pluginsConfiguration - modules = project.subprojects - .flatMap { subProject -> dokkaTaskNames.mapNotNull(subProject.tasks::findByName) } - .filterIsInstance<DokkaTask>() - .map { dokkaTask -> - GradleDokkaModuleDescription().apply { - name = dokkaTask.project.name - path = dokkaTask.project.projectDir.resolve(dokkaTask.outputDirectory) - .toRelativeString(project.file(outputDirectory)) - docFile = dokkaTask.project.projectDir.resolve(documentationFileName).absolutePath - } + modules = getSubprojectDokkaTasks(dokkaTaskNames).map { dokkaTask -> + GradleDokkaModuleDescription().apply { + name = dokkaTask.project.name + path = dokkaTask.project.projectDir.resolve(dokkaTask.outputDirectory) + .toRelativeString(project.file(outputDirectory)) + docFile = dokkaTask.project.projectDir.resolve(documentationFileName).absolutePath } + } } + + private fun getSubprojectDokkaTasks(dokkaTaskName: String): List<DokkaTask> { + return project.subprojects + .mapNotNull { subproject -> subproject.tasks.findByName(dokkaTaskName) as? DokkaTask } + } + + private fun getSubprojectDokkaTasks(dokkaTaskNames: Set<String>): List<DokkaTask> { + return dokkaTaskNames.flatMap { dokkaTaskName -> getSubprojectDokkaTasks(dokkaTaskName) } + } } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index a851ee13..5bf76880 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -37,12 +37,12 @@ open class DokkaPlugin : Plugin<Project> { project.maybeCreateDokkaPluginConfiguration(multimoduleName) project.maybeCreateDokkaRuntimeConfiguration(multimoduleName) project.tasks.register<DokkaMultimoduleTask>(multimoduleName) { - dokkaTaskNames.add(name) + dokkaTaskNames = dokkaTaskNames + name configuration() } project.tasks.register<DokkaCollectorTask>("${name}Collector") { - dokkaTaskNames.add(name) + dokkaTaskNames = dokkaTaskNames + name } } } |