From 0289c99680f71d408a52cc41896d2b8fb60376a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=9D=80=EC=9A=B0/=EA=B2=8C=EC=9E=84=ED=94=8C?= =?UTF-8?q?=EB=9E=AB=ED=8F=BC=ED=81=B4=EB=9D=BC=ED=8C=80/NE?= Date: Thu, 8 Jun 2023 01:36:30 +0900 Subject: [PATCH] Revert LinkedHashSet and addAbstractTypeMapping for objectMapper (#2999) --- core/src/main/kotlin/defaultConfiguration.kt | 5 +++-- core/src/main/kotlin/utilities/json.kt | 1 + .../testApi/testRunner/TestDokkaConfigurationBuilder.kt | 6 +++--- .../src/main/kotlin/testApi/testRunner/TestRunner.kt | 4 ++-- .../main/kotlin/org/jetbrains/dokka/GlobalArguments.kt | 2 +- .../org/jetbrains/dokka/SourceSetArgumentsParser.kt | 2 +- .../org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt | 2 +- .../jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt | 8 ++++---- .../dokka/gradle/tasks/DokkaMultiModuleTaskTest.kt | 6 +++--- runners/maven-plugin/src/main/kotlin/DokkaMojo.kt | 2 +- 10 files changed, 20 insertions(+), 18 deletions(-) diff --git a/core/src/main/kotlin/defaultConfiguration.kt b/core/src/main/kotlin/defaultConfiguration.kt index d034a4cd25e..7d9f83d73f0 100644 --- a/core/src/main/kotlin/defaultConfiguration.kt +++ b/core/src/main/kotlin/defaultConfiguration.kt @@ -1,5 +1,6 @@ package org.jetbrains.dokka +import com.fasterxml.jackson.databind.annotation.JsonDeserialize import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet import java.io.File import java.net.URL @@ -17,7 +18,7 @@ data class DokkaConfigurationImpl( override val failOnWarning: Boolean = DokkaDefaults.failOnWarning, override val delayTemplateSubstitution: Boolean = false, override val suppressObviousFunctions: Boolean = DokkaDefaults.suppressObviousFunctions, - override val includes: LinkedHashSet = linkedSetOf(), + override val includes: Set = setOf(), override val suppressInheritedMembers: Boolean = DokkaDefaults.suppressInheritedMembers, override val finalizeCoroutines: Boolean = true, ) : DokkaConfiguration @@ -36,7 +37,7 @@ data class DokkaSourceSetImpl( override val sourceRoots: Set = emptySet(), override val dependentSourceSets: Set = emptySet(), override val samples: Set = emptySet(), - override val includes: Set = linkedSetOf(), + override val includes: Set = emptySet(), @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") override val includeNonPublic: Boolean = DokkaDefaults.includeNonPublic, override val reportUndocumented: Boolean = DokkaDefaults.reportUndocumented, diff --git a/core/src/main/kotlin/utilities/json.kt b/core/src/main/kotlin/utilities/json.kt index eb666d31e3a..c082de2c14e 100644 --- a/core/src/main/kotlin/utilities/json.kt +++ b/core/src/main/kotlin/utilities/json.kt @@ -13,6 +13,7 @@ import com.fasterxml.jackson.core.type.TypeReference as JacksonTypeReference private val objectMapper = run { val module = SimpleModule().apply { addSerializer(FileSerializer) + addAbstractTypeMapping(Set::class.java, LinkedHashSet::class.java) } jacksonObjectMapper() .registerModule(module) diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt index 56d30c2081c..50ab3bad9dc 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestDokkaConfigurationBuilder.kt @@ -52,7 +52,7 @@ class TestDokkaConfigurationBuilder { modules = modules, failOnWarning = failOnWarning, suppressObviousFunctions = suppressObviousFunctions, - includes = LinkedHashSet(includes), + includes = includes.toSet(), suppressInheritedMembers = suppressInheritedMembers, delayTemplateSubstitution = delayTemplateSubstitution, finalizeCoroutines = false @@ -114,7 +114,7 @@ class DokkaSourceSetBuilder( sourceRoots = sourceRoots.map(::File).toSet(), dependentSourceSets = dependentSourceSets, samples = samples.map(::File).toSet(), - includes = LinkedHashSet(includes.map(::File)), + includes = includes.map(::File).toSet(), includeNonPublic = includeNonPublic, documentedVisibilities = documentedVisibilities, reportUndocumented = reportUndocumented, @@ -140,7 +140,7 @@ val defaultSourceSet = DokkaSourceSetImpl( sourceRoots = emptySet(), dependentSourceSets = emptySet(), samples = emptySet(), - includes = linkedSetOf(), + includes = emptySet(), includeNonPublic = false, documentedVisibilities = DokkaDefaults.documentedVisibilities, reportUndocumented = false, diff --git a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt index 4c794802dfb..31443b2d9f3 100644 --- a/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt +++ b/core/test-api/src/main/kotlin/testApi/testRunner/TestRunner.kt @@ -88,9 +88,9 @@ abstract class AbstractTest, D : DokkaTestGe localDirectory = testDirPath.toFile().resolve(link.localDirectory).absolutePath ) }.toSet(), - includes = LinkedHashSet(sourceSet.includes.map { file -> + includes = sourceSet.includes.map { file -> testDirPath.toFile().resolve(file) - }) + }.toSet() ) } ) diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt index 01188666458..29b57b72710 100644 --- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt +++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/GlobalArguments.kt @@ -78,7 +78,7 @@ class GlobalArguments(args: Array) : DokkaConfiguration { "Accepts multiple values separated by semicolons" ).delimiter(";") - override val includes: LinkedHashSet by lazy { LinkedHashSet(_includes) } + override val includes: Set by lazy { _includes.toSet() } override val suppressInheritedMembers: Boolean by parser.option( ArgType.Boolean, diff --git a/runners/cli/src/main/kotlin/org/jetbrains/dokka/SourceSetArgumentsParser.kt b/runners/cli/src/main/kotlin/org/jetbrains/dokka/SourceSetArgumentsParser.kt index 2828a50d7fc..49e8f2ae059 100644 --- a/runners/cli/src/main/kotlin/org/jetbrains/dokka/SourceSetArgumentsParser.kt +++ b/runners/cli/src/main/kotlin/org/jetbrains/dokka/SourceSetArgumentsParser.kt @@ -133,7 +133,7 @@ internal fun parseSourceSet(moduleName: String, args: Array): DokkaConfi .map { dependentSourceSetName -> dependentSourceSetName.split('/').let { DokkaSourceSetID(it[0], it[1]) } } .toMutableSet() override val samples = samples.toMutableSet() - override val includes = LinkedHashSet(includes) + override val includes = includes.toMutableSet() @Deprecated("Use [documentedVisibilities] property for a more flexible control over documented visibilities") override val includeNonPublic = includeNonPublic override val reportUndocumented = reportUndocumented diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt index 9fd063efcc6..0626fc59546 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaSourceSetMapper.kt @@ -11,7 +11,7 @@ internal fun GradleDokkaSourceSetBuilder.toDokkaSourceSetImpl(): DokkaSourceSetI sourceRoots = sourceRoots.toSet(), dependentSourceSets = dependentSourceSets.get().toSet(), samples = samples.toSet(), - includes = LinkedHashSet(includes.toList()), + includes = includes.toSet(), includeNonPublic = includeNonPublic.get(), documentedVisibilities = documentedVisibilities.get(), reportUndocumented = reportUndocumented.get(), diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt index 19ad7cbeb2f..7d6f60d2dec 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTask.kt @@ -67,9 +67,9 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() { } @get:Input - internal val childDokkaTaskIncludes: Map> + internal val childDokkaTaskIncludes: Map> get() = childDokkaTasks.filterIsInstance().associate { task -> - task.path to LinkedHashSet(task.dokkaSourceSets.flatMap { it.includes }) + task.path to task.dokkaSourceSets.flatMap { it.includes }.toSet() } // The method contains a reference to internal Gradle API that is nice not to use. @@ -101,11 +101,11 @@ abstract class DokkaMultiModuleTask : AbstractDokkaParentTask() { relativePathToOutputDirectory = targetChildOutputDirectory(dokkaTask).get().asFile.relativeTo( outputDirectory.asFile.get() ), - includes = childDokkaTaskIncludes[dokkaTask.path] ?: linkedSetOf(), + includes = childDokkaTaskIncludes[dokkaTask.path].orEmpty(), sourceOutputDirectory = dokkaTask.outputDirectory.asFile.get(), ) }, - includes = LinkedHashSet(includes.toList()), + includes = includes.toSet(), ) } } diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTaskTest.kt index d608e18811c..6df809ff71e 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTaskTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/tasks/DokkaMultiModuleTaskTest.kt @@ -101,12 +101,12 @@ class DokkaMultiModuleTaskTest { pluginsClasspath = emptyList(), failOnWarning = true, offlineMode = true, - includes = linkedSetOf(topLevelInclude), + includes = setOf(topLevelInclude), modules = listOf( DokkaModuleDescriptionImpl( name = "child", relativePathToOutputDirectory = File("child"), - includes = linkedSetOf(include1, include2), + includes = setOf(include1, include2), sourceOutputDirectory = childDokkaTask.outputDirectory.get().asFile ) ) @@ -186,7 +186,7 @@ class DokkaMultiModuleTaskTest { assertEquals( mapOf( - ":child:childDokkaTask" to linkedSetOf( + ":child:childDokkaTask" to setOf( childDokkaTaskInclude1, childDokkaTaskInclude2, childDokkaTaskInclude3 diff --git a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt index dd8e7217026..c82f1b59657 100644 --- a/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/runners/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -370,7 +370,7 @@ abstract class AbstractDokkaMojo(private val defaultDokkaPlugins: List(includes.map(::File)), + includes = includes.map(::File).toSet(), includeNonPublic = includeNonPublic, documentedVisibilities = documentedVisibilities, reportUndocumented = reportUndocumented,