aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-13 09:50:18 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-13 14:23:08 +0200
commit8ec106388209543434f990fe3af6fb02a7caceb4 (patch)
tree710340b47fde53ae4681024678ba3a5054ced440
parentec8cb8223f20e4c953f6b39e611842eabab81c3b (diff)
downloaddokka-8ec106388209543434f990fe3af6fb02a7caceb4.tar.gz
dokka-8ec106388209543434f990fe3af6fb02a7caceb4.tar.bz2
dokka-8ec106388209543434f990fe3af6fb02a7caceb4.zip
Implement DokkaTasksTest
-rw-r--r--runners/gradle-plugin/build.gradle.kts1
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt9
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt52
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/KotlinDslDokkaTaskConfigurationTest.kt1
5 files changed, 54 insertions, 11 deletions
diff --git a/runners/gradle-plugin/build.gradle.kts b/runners/gradle-plugin/build.gradle.kts
index a8345652..5762fa88 100644
--- a/runners/gradle-plugin/build.gradle.kts
+++ b/runners/gradle-plugin/build.gradle.kts
@@ -18,6 +18,7 @@ dependencies {
compileOnly(gradleApi())
compileOnly(gradleKotlinDsl())
testImplementation(gradleApi())
+ testImplementation(gradleKotlinDsl())
testImplementation(kotlin("test-junit"))
testImplementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
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 dc94cc7f..27d25884 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
@@ -23,7 +23,7 @@ open class DokkaCollectorTask : DefaultTask() {
@TaskAction
fun collect() {
- val configurations = project.allDescendentProjects().toList()
+ val configurations = project.subprojects
.filter { subProject -> subProject.name in modules }
.flatMap { subProject -> dokkaTaskNames.mapNotNull(subProject.tasks::findByName) }
.filterIsInstance<DokkaTask>()
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
index 3a7bcd0d..b6c5cbd8 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
@@ -32,15 +32,6 @@ internal fun Project.isMultiplatformProject() = try {
internal fun KotlinTarget.isAndroidTarget() = this.platformType == KotlinPlatformType.androidJvm
-internal fun Project.allDescendentProjects(): Sequence<Project> {
- return sequence {
- yieldAll(subprojects)
- subprojects.forEach { subproject ->
- yieldAll(subproject.allDescendentProjects())
- }
- }
-}
-
internal fun <T : Any> NamedDomainObjectContainer<T>.maybeCreate(name: String, configuration: T.() -> Unit): T {
return findByName(name) ?: create(name, configuration)
}
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt
new file mode 100644
index 00000000..66283876
--- /dev/null
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaTasksTest.kt
@@ -0,0 +1,52 @@
+package org.jetbrains.dokka.gradle
+
+import org.gradle.kotlin.dsl.withType
+import org.gradle.testfixtures.ProjectBuilder
+import kotlin.test.Test
+import kotlin.test.assertSame
+import kotlin.test.assertTrue
+
+class DokkaTasksTest {
+
+ @Test
+ fun `one task per format is registered`() {
+ val project = ProjectBuilder.builder().build()
+ project.plugins.apply("org.jetbrains.dokka")
+
+ assertTrue(
+ project.tasks.findByName("dokkaHtml") is DokkaTask,
+ "Expected DokkaTask: dokkaHtml"
+ )
+
+ assertTrue(
+ project.tasks.findByName("dokkaGfm") is DokkaTask,
+ "Expected DokkaTask: dokkaGfm"
+ )
+
+ assertTrue(
+ project.tasks.findByName("dokkaJekyll") is DokkaTask,
+ "Expected DokkaTask: dokkaJekyll"
+ )
+
+ assertTrue(
+ project.tasks.findByName("dokkaJavadoc") is DokkaTask,
+ "Expected DokkaTask: dokkaJavadoc"
+ )
+ }
+
+ @Test
+ fun `dokka plugin configurations extend dokkaPlugin`() {
+ val project = ProjectBuilder.builder().build()
+ project.plugins.apply("org.jetbrains.dokka")
+
+ val dokkaPluginsConfiguration = project.maybeCreateDokkaDefaultPluginConfiguration()
+
+ project.tasks.withType<DokkaTask>().forEach { dokkaTask ->
+ assertSame(
+ dokkaTask.plugins.extendsFrom.single(), dokkaPluginsConfiguration,
+ "Expected dokka plugins configuration to extend default ${dokkaPluginsConfiguration.name} 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
index b4b54957..7b78fb55 100644
--- 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
@@ -1,6 +1,5 @@
package org.jetbrains.dokka.gradle
-import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.testfixtures.ProjectBuilder
import org.jetbrains.dokka.DokkaSourceSetID
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension