aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md11
-rw-r--r--runners/gradle-plugin/build.gradle.kts2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt8
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt19
4 files changed, 33 insertions, 7 deletions
diff --git a/README.md b/README.md
index eab270e7..6abc761c 100644
--- a/README.md
+++ b/README.md
@@ -52,13 +52,12 @@ dokka {
Kotlin
```kotlin
-tasks {
- val dokka by getting(DokkaTask::class) {
- outputFormat = "html"
- outputDirectory = "$buildDir/dokka"
- }
+dokka {
+ outputFormat = "html"
+ outputDirectory = "$buildDir/dokka"
}
```
+You may need to add an `import org.jetbrains.dokka.gradle.dokka` to the top of `build.gradle.kts` in this case.
[Output formats](#output_formats)
@@ -225,7 +224,7 @@ kotlin { // Kotlin Multiplatform plugin configuration
js("customName")
}
-val dokka by getting(DokkaTask::class) {
+dokka {
outputDirectory = "$buildDir/dokka"
outputFormat = "html"
diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts
index df4a8738..d2e9eccd 100644
--- a/runners/gradle-plugin/build.gradle.kts
+++ b/runners/gradle-plugin/build.gradle.kts
@@ -16,6 +16,8 @@ dependencies {
compileOnly("com.android.tools.build:builder-model:3.0.0")
compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
+ testImplementation(gradleApi())
+ testImplementation(kotlin("test-junit"))
constraints {
val kotlin_version: String by project
compileOnly("org.jetbrains.kotlin:kotlin-reflect:${kotlin_version}") {
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 d72ec0f9..2de95493 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
@@ -341,4 +341,10 @@ open class DokkaTask : DefaultTask(), Configurable {
null
}
}
-} \ No newline at end of file
+}
+
+fun Project.dokka(configuration: DokkaTask.() -> Unit) {
+ tasks.withType(DokkaTask::class.java) { dokkaTask ->
+ dokkaTask.configuration()
+ }
+}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt
new file mode 100644
index 00000000..0b80f4a2
--- /dev/null
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt
@@ -0,0 +1,19 @@
+package org.jetbrains.dokka.gradle
+
+import org.gradle.testfixtures.ProjectBuilder
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class KotlinDslDokkaTaskConfigurationTest {
+
+ @Test
+ fun `configure project using dokka extension function`() {
+ val project = ProjectBuilder.builder().build()
+ project.plugins.apply("org.jetbrains.dokka")
+ project.dokka { this.outputFormat = "test" }
+
+ project.tasks.withType(DokkaTask::class.java).forEach { dokkaTask ->
+ assertEquals("test", dokkaTask.outputFormat)
+ }
+ }
+}