From 8cd28416817dfd7d28bb66b28e849d97cc09012b Mon Sep 17 00:00:00 2001 From: "sebastian.sellmair" Date: Thu, 27 Aug 2020 15:50:40 +0200 Subject: Let module name be configurable withing `AbstractDokkaTask` and remove concept of `moduleDisplayName` --- .../gradle/ConfigureWithKotlinSourceSetGistTest.kt | 2 -- .../dokka/gradle/DokkaCollectorTaskTest.kt | 2 ++ .../dokka/gradle/DokkaConfigurationJsonTest.kt | 1 - .../gradle/DokkaConfigurationSerializableTest.kt | 1 - .../dokka/gradle/DokkaMultiModuleTaskTest.kt | 2 ++ .../dokka/gradle/GradleDokkaSourceSetBuilder.kt | 11 ++++++ .../gradle/GradleDokkaSourceSetBuilderTest.kt | 39 ++++++---------------- .../gradle/KotlinDslDokkaTaskConfigurationTest.kt | 6 ++-- 8 files changed, 29 insertions(+), 35 deletions(-) create mode 100644 runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt (limited to 'runners/gradle-plugin/src/test/kotlin') diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt index efe03c56..c06a3992 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt @@ -1,9 +1,7 @@ package org.jetbrains.dokka.gradle import org.gradle.api.artifacts.FileCollectionDependency -import org.gradle.api.file.ConfigurableFileCollection import org.gradle.kotlin.dsl.get -import org.gradle.kotlin.dsl.property import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.Platform import org.jetbrains.dokka.gradle.kotlin.KotlinSourceSetGist diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt index 04dd1eed..6e9bef38 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTaskTest.kt @@ -33,6 +33,7 @@ class DokkaCollectorTaskTest { val collectorTasks = rootProject.tasks.withType() collectorTasks.configureEach { task -> + task.moduleName by "custom Module Name" task.outputDirectory by File("customOutputDirectory") task.cacheRoot by File("customCacheRoot") task.failOnWarning by true @@ -45,6 +46,7 @@ class DokkaCollectorTaskTest { val dokkaConfiguration = task.buildDokkaConfiguration() assertEquals( DokkaConfigurationImpl( + moduleName = "custom Module Name", outputDir = File("customOutputDirectory"), cacheRoot = File("customCacheRoot"), failOnWarning = true, diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt index 29532877..d1bfb0e1 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt @@ -28,7 +28,6 @@ class DokkaConfigurationJsonTest { this.pluginsConfiguration.put("0", "a") this.pluginsConfiguration.put("1", "b") this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.moduleDisplayName by "moduleDisplayName" sourceSet.displayName by "customSourceSetDisplayName" sourceSet.reportUndocumented by true diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt index f22a5b8c..99fca12d 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -35,7 +35,6 @@ class DokkaConfigurationSerializableTest { this.pluginsConfiguration.put("0", "a") this.pluginsConfiguration.put("1", "b") this.dokkaSourceSets.create("main") { sourceSet -> - sourceSet.moduleDisplayName by "moduleDisplayName" sourceSet.displayName by "customSourceSetDisplayName" sourceSet.reportUndocumented by true diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt index 62c867ba..5b9413c8 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaMultiModuleTaskTest.kt @@ -58,6 +58,7 @@ class DokkaMultiModuleTaskTest { assertTrue(multimoduleTasks.isNotEmpty(), "Expected at least one multimodule task") multimoduleTasks.configureEach { task -> + task.moduleName by "custom Module Name" task.documentationFileName by "customDocumentationFileName.md" task.outputDirectory by task.project.buildDir.resolve("customOutputDirectory") task.cacheRoot by File("customCacheRoot") @@ -70,6 +71,7 @@ class DokkaMultiModuleTaskTest { val dokkaConfiguration = task.buildDokkaConfiguration() assertEquals( DokkaConfigurationImpl( + moduleName = "custom Module Name", outputDir = task.project.buildDir.resolve("customOutputDirectory"), cacheRoot = File("customCacheRoot"), pluginsConfiguration = mapOf("pluginA" to "configA"), diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt new file mode 100644 index 00000000..c555985b --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -0,0 +1,11 @@ +@file:Suppress("TestFunctionName") + +package org.jetbrains.dokka.gradle + +import org.gradle.api.Project +import org.jetbrains.dokka.DokkaSourceSetID + +fun GradleDokkaSourceSetBuilder(name: String, project: Project, sourceSetScopeId: String = "${project.path}:test"): + GradleDokkaSourceSetBuilder { + return GradleDokkaSourceSetBuilder(name, project) { DokkaSourceSetID(sourceSetScopeId, it) } +} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt index c1053069..920c48b4 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderTest.kt @@ -1,6 +1,9 @@ +@file:Suppress("TestFunctionName") + package org.jetbrains.dokka.gradle import com.android.build.gradle.internal.api.DefaultAndroidSourceSet +import org.gradle.api.Project import org.gradle.kotlin.dsl.closureOf import org.gradle.testfixtures.ProjectBuilder import org.jetbrains.dokka.* @@ -15,14 +18,14 @@ class GradleDokkaSourceSetBuilderTest { @Test fun sourceSetId() { - val sourceSet = GradleDokkaSourceSetBuilder("myName", project) + val sourceSet = GradleDokkaSourceSetBuilder("myName", project, "scopeId") assertEquals( - DokkaSourceSetID(project, "myName"), sourceSet.sourceSetID, + DokkaSourceSetID("scopeId", "myName"), sourceSet.sourceSetID, "Expected sourceSet.sourceSetID to match output of DokkaSourceSetID factory function" ) assertEquals( - ":/myName", sourceSet.sourceSetID.toString(), + "scopeId/myName", sourceSet.sourceSetID.toString(), "Expected SourceSetId's string representation" ) } @@ -45,29 +48,6 @@ class GradleDokkaSourceSetBuilderTest { ) } - @Test - fun moduleDisplayName() { - val sourceSet = GradleDokkaSourceSetBuilder("myName", project) - - assertNull( - sourceSet.moduleDisplayName.getSafe(), - "Expected no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set by default" - ) - - assertEquals( - "root", sourceSet.build().moduleDisplayName, - "Expected project name being used for ${DokkaConfiguration.DokkaSourceSet::moduleDisplayName.name} " + - "after building source set with no ${GradleDokkaSourceSetBuilder::moduleDisplayName.name} being set" - ) - - sourceSet.moduleDisplayName by "displayName" - - assertEquals( - "displayName", sourceSet.build().moduleDisplayName, - "Expected previously set ${GradleDokkaSourceSetBuilder::displayName.name} to be present after build" - ) - } - @Test fun displayName() { val sourceSet = GradleDokkaSourceSetBuilder("myName", project) @@ -128,9 +108,9 @@ class GradleDokkaSourceSetBuilderTest { val sourceSet = GradleDokkaSourceSetBuilder("", project) assertEquals(emptySet(), sourceSet.build().dependentSourceSets, "Expected no dependent sourceSets by default") - sourceSet.dependentSourceSets.add(DokkaSourceSetID(project, "s1")) + sourceSet.dependentSourceSets.add(sourceSet.DokkaSourceSetID("s1")) sourceSet.dependsOn("s2") - sourceSet.dependsOn(DokkaSourceSetID(project, "s3")) + sourceSet.dependsOn(sourceSet.DokkaSourceSetID("s3")) sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s4", project)) sourceSet.dependsOn(GradleDokkaSourceSetBuilder("s5", project).build()) sourceSet.dependsOn(DefaultKotlinSourceSet(project, "s6")) @@ -456,3 +436,6 @@ class GradleDokkaSourceSetBuilderTest { ) } } + +private fun GradleDokkaSourceSetBuilder(name: String, project: Project) = + GradleDokkaSourceSetBuilder(name, project, project.path) 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 6a356b79..9c788a01 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 @@ -50,7 +50,7 @@ class KotlinDslDokkaTaskConfigurationTest { ) assertEquals( - DokkaSourceSetID(project.path, "commonMain"), commonMain.sourceSetID + DokkaSourceSetID(dokkaTask, "commonMain"), commonMain.sourceSetID ) } } @@ -83,14 +83,14 @@ class KotlinDslDokkaTaskConfigurationTest { val kotlin = project.extensions.getByName("kotlin") as KotlinJvmProjectExtension - project.tasks.withType(DokkaTask::class.java).first().run { + project.tasks.withType(DokkaTask::class.java).first().apply { dokkaSourceSets.run { val special = create("special") { it.dependsOn(kotlin.sourceSets.getByName("main")) } assertEquals( - DokkaSourceSetID(project, "main"), special.dependentSourceSets.get().single() + DokkaSourceSetID(this@apply, "main"), special.dependentSourceSets.get().single() ) } } -- cgit