Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing group and description for Multimodule tasks #2806

Merged
merged 10 commits into from Feb 1, 2023
Expand Up @@ -4,6 +4,7 @@ import org.gradle.api.DefaultTask
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.Dependency
import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.kotlin.dsl.register
import org.gradle.util.GradleVersion

Expand Down Expand Up @@ -74,6 +75,8 @@ open class DokkaPlugin : Plugin<Project> {
}

project.tasks.register<DefaultTask>("${name}Multimodule") {
group = JavaBasePlugin.DOCUMENTATION_GROUP
IgnatBeresnev marked this conversation as resolved.
Show resolved Hide resolved
description = "DEPRECATED: 'Multimodule' is deprecated. Use 'MultiModule' instead."
dependsOn(multiModuleName)
doLast {
logger.warn("'Multimodule' is deprecated. Use 'MultiModule' instead")
Expand Down
@@ -1,6 +1,7 @@
package org.jetbrains.dokka.gradle

import org.gradle.api.plugins.JavaBasePlugin
import org.gradle.api.tasks.TaskContainer
import org.gradle.kotlin.dsl.withType
import org.gradle.testfixtures.ProjectBuilder
import kotlin.test.Test
Expand Down Expand Up @@ -55,24 +56,34 @@ class DokkaPluginApplyTest {
fun `all dokka tasks are part of the documentation group`() {
val project = ProjectBuilder.builder().build()
project.plugins.apply("org.jetbrains.dokka")
project.tasks.filter { "dokka" in it.name.toLowerCase() }.forEach { dokkaTask ->
assertEquals(
JavaBasePlugin.DOCUMENTATION_GROUP, dokkaTask.group,
"Expected task: ${dokkaTask.path} group to be ${JavaBasePlugin.DOCUMENTATION_GROUP}"
)
}
assertTasksHaveDocumentationGroup(project.tasks)
}

@Test
fun `all dokka tasks are part of the documentation group in a multi module setup`() {
val root = ProjectBuilder.builder().withName("root").build()
val child = ProjectBuilder.builder().withName("child").withParent(root).build()
root.plugins.apply("org.jetbrains.dokka")
child.plugins.apply("org.jetbrains.dokka")
assertTasksHaveDocumentationGroup(root.tasks)
assertTasksHaveDocumentationGroup(child.tasks)
}

@Test
fun `all dokka tasks provide a task description`() {
val project = ProjectBuilder.builder().build()
project.plugins.apply("org.jetbrains.dokka")
project.tasks.filter { "dokka" in it.name.toLowerCase() }.forEach { dokkaTask ->
assertTrue(
dokkaTask.description.orEmpty().isNotEmpty(),
"Expected description for task ${dokkaTask.name}"
)
}
assertTasksHaveDescription(project.tasks)
}

@Test
fun `all dokka tasks provide a task description in a multi module setup`() {
val root = ProjectBuilder.builder().withName("root").build()
val child = ProjectBuilder.builder().withName("child").withParent(root).build()
root.plugins.apply("org.jetbrains.dokka")
child.plugins.apply("org.jetbrains.dokka")
assertTasksHaveDescription(root.tasks)
assertTasksHaveDescription(child.tasks)
}

@Test
Expand All @@ -94,3 +105,21 @@ class DokkaPluginApplyTest {
}
}
}

private fun assertTasksHaveDocumentationGroup(taskContainer: TaskContainer) {
taskContainer.filter { "dokka" in it.name.toLowerCase() }.forEach { dokkaTask ->
assertEquals(
JavaBasePlugin.DOCUMENTATION_GROUP, dokkaTask.group,
"Expected task: ${dokkaTask.path} group to be ${JavaBasePlugin.DOCUMENTATION_GROUP}"
)
}
}

private fun assertTasksHaveDescription(taskContainer: TaskContainer) {
taskContainer.filter { "dokka" in it.name.toLowerCase() }.forEach { dokkaTask ->
assertTrue(
dokkaTask.description.orEmpty().isNotEmpty(),
"Expected description for task ${dokkaTask.name}"
)
}
}