From 8c3396d480a35df33d999ca056fae7830ea11025 Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Fri, 10 Jul 2020 08:43:57 +0200 Subject: Implement defaultDokkaOutputDirectory --- .../kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt | 2 +- .../org/jetbrains/dokka/gradle/DokkaMultimoduleTask.kt | 2 +- .../src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 2 +- .../jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt | 13 +++++++++++++ .../src/main/kotlin/org/jetbrains/dokka/gradle/main.kt | 5 +---- 5 files changed, 17 insertions(+), 7 deletions(-) create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka') 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 da834775..dc94cc7f 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 @@ -14,7 +14,7 @@ open class DokkaCollectorTask : DefaultTask() { var modules: List = emptyList() @Input - var outputDirectory: String = "" + var outputDirectory: String = defaultDokkaOutputDirectory().absolutePath private lateinit var configuration: GradleDokkaConfigurationImpl 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 76a2e80a..dd0a5d04 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 @@ -21,7 +21,7 @@ open class DokkaMultimoduleTask : DefaultTask(), Configurable { var documentationFileName: String = "README.md" @Input - var outputDirectory: String = "" + var outputDirectory: String = defaultDokkaOutputDirectory().absolutePath @Input val dokkaTaskNames: MutableSet = mutableSetOf() 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 bc2fa769..b755c5aa 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 @@ -44,7 +44,7 @@ open class DokkaTask : DefaultTask(), Configurable { } @Input - var outputDirectory: String = "" + var outputDirectory: String = defaultDokkaOutputDirectory().absolutePath @Input var subProjects: List = emptyList() diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt new file mode 100644 index 00000000..0a7ab534 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/defaultDokkaOutputDirectory.kt @@ -0,0 +1,13 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.Task +import java.io.File + +internal fun Task.defaultDokkaOutputDirectory(): File { + return defaultDokkaOutputDirectory(project.buildDir, name) +} + +internal fun defaultDokkaOutputDirectory(buildDir: File, taskName: String): File { + val formatClassifier = taskName.removePrefix("dokka").decapitalize() + return File(buildDir, "dokka${File.separator}$formatClassifier") +} 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 df854cd9..7fb0fe7d 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 @@ -3,11 +3,11 @@ package org.jetbrains.dokka.gradle import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.kotlin.dsl.create -import java.io.File open class DokkaPlugin : Plugin { override fun apply(project: Project) { project.createDokkaTasks("dokka") { + outputDirectory = defaultDokkaOutputDirectory(project.buildDir, "dokkaKdoc").absolutePath doFirst { logger.warn(":dokka task is deprecated in favor of :dokkaKdoc") } @@ -43,17 +43,14 @@ open class DokkaPlugin : Plugin { */ private fun Project.createDokkaTasks(name: String, configuration: DokkaTask.() -> Unit = {}) { project.tasks.create(name) { - outputDirectory = File(buildDir, name).absolutePath configuration() } project.tasks.create("${name}Collector") { - outputDirectory = File(buildDir, name).absolutePath dokkaTaskNames.add(name) } project.tasks.create("${name}Multimodule") { - outputDirectory = File(buildDir, name).absolutePath dokkaTaskNames.add(name) } } -- cgit