From d41965ca3cb180bc82bd5dd6fa747d2b83381b31 Mon Sep 17 00:00:00 2001 From: Paweł Marks Date: Wed, 7 Oct 2020 19:36:49 +0200 Subject: Implement immediate temaplates resolution --- .../org/jetbrains/dokka/gradle/DokkaTaskPartial.kt | 50 ++++++++++++++++++++++ .../main/kotlin/org/jetbrains/dokka/gradle/main.kt | 8 +++- 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTaskPartial.kt (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains') diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTaskPartial.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTaskPartial.kt new file mode 100644 index 00000000..0f509d3b --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTaskPartial.kt @@ -0,0 +1,50 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.NamedDomainObjectContainer +import org.gradle.api.internal.plugins.DslObject +import org.gradle.api.tasks.Internal +import org.gradle.api.tasks.Nested +import org.jetbrains.dokka.DokkaConfigurationImpl +import org.jetbrains.dokka.build + +abstract class DokkaTaskPartial : AbstractDokkaTask() { + + @get:Internal + val dokkaSourceSets: NamedDomainObjectContainer = + project.container(GradleDokkaSourceSetBuilder::class.java, gradleDokkaSourceSetBuilderFactory()) + .also { container -> + DslObject(this).extensions.add("dokkaSourceSets", container) + project.kotlinOrNull?.sourceSets?.all { kotlinSourceSet -> + container.register(kotlinSourceSet.name) { dokkaSourceSet -> + dokkaSourceSet.configureWithKotlinSourceSet(kotlinSourceSet) + } + } + } + + /** + * Only contains source sets that are marked with `isDocumented`. + * Non documented source sets are not relevant for Gradle's UP-TO-DATE mechanism, as well + * as task dependency graph. + */ + @get:Nested + protected val unsuppressedSourceSets: List + get() = dokkaSourceSets + .toList() + .also(::checkSourceSetDependencies) + .filterNot { it.suppress.getSafe() } + + override fun buildDokkaConfiguration(): DokkaConfigurationImpl { + return DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), + moduleVersion = moduleVersion.orNull, + outputDir = outputDirectory.getSafe(), + cacheRoot = cacheRoot.getSafe(), + offlineMode = offlineMode.getSafe(), + failOnWarning = failOnWarning.getSafe(), + sourceSets = unsuppressedSourceSets.build(), + pluginsConfiguration = buildPluginsConfiguration(), + pluginsClasspath = plugins.resolve().toList(), + delayTemplateSubstitution = true + ) + } +} \ No newline at end of file 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 1cda5c39..99e6e7e3 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 @@ -47,6 +47,12 @@ open class DokkaPlugin : Plugin { configuration() } + if (project.parent != null) { + project.tasks.register("${name}Partial") { + configuration() + } + } + if (project.subprojects.isNotEmpty()) { if (multiModuleTaskSupported) { val multiModuleName = "${name}MultiModule" @@ -54,7 +60,7 @@ open class DokkaPlugin : Plugin { project.maybeCreateDokkaRuntimeConfiguration(multiModuleName) project.tasks.register(multiModuleName) { - addSubprojectChildTasks(name) + addSubprojectChildTasks("${name}Partial") configuration() description = "Runs all subprojects '$name' tasks and generates module navigation page" plugins.dependencies.add(project.dokkaArtifacts.allModulesPage) -- cgit