diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-10-07 19:36:49 +0200 |
---|---|---|
committer | Błażej Kardyś <bkardys@virtuslab.com> | 2020-11-27 03:15:02 +0100 |
commit | d41965ca3cb180bc82bd5dd6fa747d2b83381b31 (patch) | |
tree | 5660f17f21fdf5871c8239f4d96c4521545292d1 /runners/gradle-plugin/src/main | |
parent | dc179bf9a649d925e7e64dbcaf52a2187416a1d5 (diff) | |
download | dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.tar.gz dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.tar.bz2 dokka-d41965ca3cb180bc82bd5dd6fa747d2b83381b31.zip |
Implement immediate temaplates resolution
Diffstat (limited to 'runners/gradle-plugin/src/main')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTaskPartial.kt | 50 | ||||
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt | 8 |
2 files changed, 57 insertions, 1 deletions
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<GradleDokkaSourceSetBuilder> = + 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<GradleDokkaSourceSetBuilder> + 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<Project> { configuration() } + if (project.parent != null) { + project.tasks.register<DokkaTaskPartial>("${name}Partial") { + configuration() + } + } + if (project.subprojects.isNotEmpty()) { if (multiModuleTaskSupported) { val multiModuleName = "${name}MultiModule" @@ -54,7 +60,7 @@ open class DokkaPlugin : Plugin<Project> { project.maybeCreateDokkaRuntimeConfiguration(multiModuleName) project.tasks.register<DokkaMultiModuleTask>(multiModuleName) { - addSubprojectChildTasks(name) + addSubprojectChildTasks("${name}Partial") configuration() description = "Runs all subprojects '$name' tasks and generates module navigation page" plugins.dependencies.add(project.dokkaArtifacts.allModulesPage) |