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` --- runners/cli/src/main/kotlin/cli/main.kt | 39 ++++++++++----------- runners/gradle-plugin/MIGRATION.md | 2 +- .../jetbrains/dokka/gradle/AbstractDokkaTask.kt | 4 +++ .../jetbrains/dokka/gradle/DokkaCollectorTask.kt | 1 + .../jetbrains/dokka/gradle/DokkaMultiModuleTask.kt | 4 ++- .../kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt | 3 +- .../dokka/gradle/GradleDokkaSourceSetBuilder.kt | 40 +++++----------------- .../GradleDokkaSourceSetBuilderExtensions.kt | 17 +++++++++ .../gradle/GradleDokkaSourceSetBuilderFactory.kt | 9 +++++ .../dokka/gradle/dokkaSourceSetIDFactory.kt | 11 ++++-- .../jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt | 6 ---- .../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 ++-- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 9 ++--- 20 files changed, 102 insertions(+), 107 deletions(-) create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt create mode 100644 runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt create mode 100644 runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt (limited to 'runners') diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 069ef166..9f7755f6 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -2,13 +2,11 @@ package org.jetbrains.dokka import kotlinx.cli.* import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet.* import org.jetbrains.dokka.utilities.DokkaConsoleLogger import org.jetbrains.dokka.utilities.cast import java.io.* import java.net.MalformedURLException import java.net.URL -import java.nio.file.Files import java.nio.file.Paths class GlobalArguments(args: Array) : DokkaConfiguration { @@ -17,6 +15,14 @@ class GlobalArguments(args: Array) : DokkaConfiguration { val json: String? by parser.argument(ArgType.String, description = "Json file name").optional() + private val _moduleName = parser.option( + ArgType.String, + description = "Name of the documentation module", + fullName = "moduleName" + ).required() + + override val moduleName: String by _moduleName + override val outputDir by parser.option(ArgTypeFile, description = "Output directory path") .default(DokkaDefaults.outputDir) @@ -26,7 +32,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { ) override val sourceSets by parser.option( - ArgTypeArgument, + ArgTypeArgument(_moduleName), description = "Single dokka source set", fullName = "sourceSet" ).multiple() @@ -68,7 +74,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { ).delimiter(";") val helpSourceSet by parser.option( - ArgTypeHelpSourceSet, + ArgTypeHelpSourceSet(_moduleName), description = "Prints help for single -sourceSet" ) @@ -103,21 +109,10 @@ class GlobalArguments(args: Array) : DokkaConfiguration { } } -private fun parseSourceSet(args: Array): DokkaConfiguration.DokkaSourceSet { +private fun parseSourceSet(moduleName: String, args: Array): DokkaConfiguration.DokkaSourceSet { val parser = ArgParser("sourceSet", prefixStyle = ArgParser.OptionPrefixStyle.JVM) - val moduleName by parser.option( - ArgType.String, - description = "Name of the documentation module", - fullName = "moduleName" - ).required() - - val moduleDisplayName by parser.option( - ArgType.String, - description = "Name of the documentation module" - ) - val sourceSetName by parser.option( ArgType.String, description = "Name of the source set" @@ -218,7 +213,6 @@ private fun parseSourceSet(args: Array): DokkaConfiguration.DokkaSourceS parser.parse(args) return object : DokkaConfiguration.DokkaSourceSet { - override val moduleDisplayName = moduleDisplayName ?: moduleName override val displayName = displayName override val sourceSetID = DokkaSourceSetID(moduleName, sourceSetName) override val classpath = classpath.toMutableList() @@ -281,17 +275,20 @@ object ArgTypeSourceLinkDefinition : ArgType(true) { +data class ArgTypeArgument(val moduleName: CLIEntity) : + ArgType(true) { override fun convert(value: kotlin.String, name: kotlin.String): DokkaConfiguration.DokkaSourceSet = - parseSourceSet(value.split(" ").filter { it.isNotBlank() }.toTypedArray()) + parseSourceSet(moduleName.value, value.split(" ").filter { it.isNotBlank() }.toTypedArray()) override val description: kotlin.String get() = "" } // Workaround for printing nested parsers help -object ArgTypeHelpSourceSet : ArgType(false) { - override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { parseSourceSet(arrayOf("-h")) } +data class ArgTypeHelpSourceSet(val moduleName: CLIEntity) : ArgType(false) { + override fun convert(value: kotlin.String, name: kotlin.String): Any = Any().also { + parseSourceSet(moduleName.value, arrayOf("-h")) + } override val description: kotlin.String get() = "" diff --git a/runners/gradle-plugin/MIGRATION.md b/runners/gradle-plugin/MIGRATION.md index 555ce66e..527c3e66 100644 --- a/runners/gradle-plugin/MIGRATION.md +++ b/runners/gradle-plugin/MIGRATION.md @@ -68,7 +68,7 @@ tasks.dokkaHtml.configure { #### Properties ```kotlin /* 0.10.x */ moduleName = "myModule" -/* 1.4.x */ moduleDisplayName.set("myModule") +/* 1.4.x */ /* Use AbstractDokkaTask#moduleName instead */ /* 0.10.x */ includeNonPublic = false /* 1.4.x */ includeNonPublic.set(false) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt index 89308e2a..b4800124 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaTask.kt @@ -24,6 +24,10 @@ abstract class AbstractDokkaTask( private val bootstrapClass: KClass = DokkaBootstrap::class ) : DefaultTask() { + @Input + val moduleName: Property = project.objects.safeProperty() + .safeConvention(project.name) + @OutputDirectory val outputDirectory: Property = project.objects.safeProperty() .safeConvention(defaultDokkaOutputDirectory()) 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 532e9e84..cd53398a 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 @@ -11,6 +11,7 @@ abstract class DokkaCollectorTask : AbstractDokkaParentTask() { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { val initialDokkaConfiguration = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), failOnWarning = failOnWarning.getSafe(), 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 2e7b7490..82e2148f 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 @@ -3,6 +3,8 @@ package org.jetbrains.dokka.gradle import org.gradle.api.internal.tasks.TaskDependencyInternal import org.gradle.api.provider.Property import org.gradle.api.tasks.* +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import org.jetbrains.dokka.DokkaConfigurationImpl import org.jetbrains.dokka.DokkaModuleDescriptionImpl import org.jetbrains.dokka.DokkaMultimoduleBootstrapImpl @@ -51,6 +53,7 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo } override fun buildDokkaConfiguration(): DokkaConfigurationImpl = DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), pluginsConfiguration = pluginsConfiguration.getSafe(), @@ -67,4 +70,3 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask(DokkaMultimoduleBo ) } - 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 d07873d8..beec3a7e 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 @@ -12,7 +12,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { @get:Internal val dokkaSourceSets: NamedDomainObjectContainer = - project.container(GradleDokkaSourceSetBuilder::class.java, GradleDokkaSourceSetBuilderFactory()) + project.container(GradleDokkaSourceSetBuilder::class.java, gradleDokkaSourceSetBuilderFactory()) .also { container -> DslObject(this).extensions.add("dokkaSourceSets", container) project.kotlinOrNull?.sourceSets?.all { kotlinSourceSet -> @@ -36,6 +36,7 @@ abstract class DokkaTask : AbstractDokkaTask(DokkaBootstrapImpl::class) { override fun buildDokkaConfiguration(): DokkaConfigurationImpl { return DokkaConfigurationImpl( + moduleName = moduleName.getSafe(), outputDir = outputDirectory.getSafe(), cacheRoot = cacheRoot.getSafe(), offlineMode = offlineMode.getSafe(), diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt index bb44eb52..d3a6c587 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilder.kt @@ -1,12 +1,10 @@ @file:Suppress("FunctionName", "UnstableApiUsage") +@file:JvmName("GradleDokkaSourceSetBuilderKt") package org.jetbrains.dokka.gradle -import com.android.build.gradle.api.AndroidSourceSet import groovy.lang.Closure -import org.gradle.api.Action -import org.gradle.api.Project -import org.gradle.api.Task +import org.gradle.api.* import org.gradle.api.file.ConfigurableFileCollection import org.gradle.api.provider.ListProperty import org.gradle.api.provider.Property @@ -16,21 +14,17 @@ import org.gradle.kotlin.dsl.listProperty import org.gradle.kotlin.dsl.setProperty import org.gradle.util.ConfigureUtil import org.jetbrains.dokka.* -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet import java.io.File import java.net.URL -internal fun Task.GradleDokkaSourceSetBuilderFactory(): (name: String) -> GradleDokkaSourceSetBuilder = - { name -> GradleDokkaSourceSetBuilder(name, project) } - - -open class GradleDokkaSourceSetBuilder constructor( +open class GradleDokkaSourceSetBuilder( @Transient @get:Input val name: String, - @Transient @get:Internal internal val project: Project + @Transient @get:Internal internal val project: Project, + @Transient @get:Internal internal val sourceSetIdFactory: NamedDomainObjectFactory, ) : DokkaConfigurationBuilder { - @Internal - val sourceSetID: DokkaSourceSetID = DokkaSourceSetID(project, name) + @Input + val sourceSetID: DokkaSourceSetID = sourceSetIdFactory.create(name) @Input val suppress: Property = project.objects.safeProperty() @@ -40,10 +34,6 @@ open class GradleDokkaSourceSetBuilder constructor( @Optional val classpath: ConfigurableFileCollection = project.files() - @Input - @Optional - val moduleDisplayName: Property = project.objects.safeProperty() - @Input @Optional val displayName: Property = project.objects.safeProperty() @@ -125,9 +115,7 @@ open class GradleDokkaSourceSetBuilder constructor( val platform: Property = project.objects.safeProperty() .safeConvention(Platform.DEFAULT) - fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = - DokkaSourceSetID(project, sourceSetName) - + fun DokkaSourceSetID(sourceSetName: String): DokkaSourceSetID = sourceSetIdFactory.create(sourceSetName) fun dependsOn(sourceSet: SourceSet) { dependsOn(DokkaSourceSetID(sourceSet.name)) @@ -208,15 +196,3 @@ open class GradleDokkaSourceSetBuilder constructor( override fun build(): DokkaSourceSetImpl = toDokkaSourceSetImpl() } - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { - dependsOn(DokkaSourceSetID(sourceSet.name)) -} - -fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { - configureWithKotlinSourceSet(kotlinSourceSet) -} diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt new file mode 100644 index 00000000..c5c7428f --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderExtensions.kt @@ -0,0 +1,17 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.api.AndroidSourceSet +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: KotlinSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.dependsOn(sourceSet: AndroidSourceSet) { + dependsOn(DokkaSourceSetID(sourceSet.name)) +} + +fun GradleDokkaSourceSetBuilder.kotlinSourceSet(kotlinSourceSet: KotlinSourceSet) { + configureWithKotlinSourceSet(kotlinSourceSet) +} + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt new file mode 100644 index 00000000..49c489c7 --- /dev/null +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/GradleDokkaSourceSetBuilderFactory.kt @@ -0,0 +1,9 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task + +@Suppress("ObjectLiteralToLambda") // Will fail at runtime in Gradle versions <= 6.6 +fun AbstractDokkaTask.gradleDokkaSourceSetBuilderFactory(): NamedDomainObjectFactory = + NamedDomainObjectFactory { name -> GradleDokkaSourceSetBuilder(name, project, DokkaSourceSetIdFactory()) } + diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt index 3fadb4fd..41cc19e3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/dokkaSourceSetIDFactory.kt @@ -2,9 +2,14 @@ package org.jetbrains.dokka.gradle -import org.gradle.api.Project +import org.gradle.api.NamedDomainObjectFactory +import org.gradle.api.Task import org.jetbrains.dokka.DokkaSourceSetID -internal fun DokkaSourceSetID(project: Project, sourceSetName: String): DokkaSourceSetID { - return DokkaSourceSetID(moduleName = project.path, sourceSetName = sourceSetName) +internal fun DokkaSourceSetID(task: Task, sourceSetName: String): DokkaSourceSetID { + return DokkaSourceSetID(task.path, sourceSetName) +} + +internal fun Task.DokkaSourceSetIdFactory() = NamedDomainObjectFactory { name -> + DokkaSourceSetID(this@DokkaSourceSetIdFactory, name) } diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt index 0f9d4053..2813d04e 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/toDokkaSourceSetImpl.kt @@ -6,7 +6,6 @@ import java.io.File internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetImpl = DokkaSourceSetImpl( classpath = classpath.toList(), - moduleDisplayName = moduleNameOrDefault(), displayName = displayNameOrDefault(), sourceSetID = sourceSetID, sourceRoots = sourceRoots.toSet(), @@ -29,11 +28,6 @@ internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetI analysisPlatform = platform.getSafe() ) - -private fun GradleDokkaSourceSetBuilder.moduleNameOrDefault(): String { - return moduleDisplayName.getSafe() ?: project.name -} - private fun GradleDokkaSourceSetBuilder.displayNameOrDefault(): String { displayName.getSafe()?.let { return it } if (name.endsWith("Main") && name != "Main") { 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() ) } } diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index b95b94c0..4e5e053a 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -101,9 +101,6 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List