diff options
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains')
-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) |