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

Fix loading empty properties by CLI json parser. #2362

Merged
merged 1 commit into from Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/main/kotlin/defaultConfiguration.kt
Expand Up @@ -42,9 +42,9 @@ data class DokkaSourceSetImpl(
override val skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages,
override val skipDeprecated: Boolean = DokkaDefaults.skipDeprecated,
override val jdkVersion: Int = DokkaDefaults.jdkVersion,
override val sourceLinks: Set<SourceLinkDefinitionImpl> = emptySet(),
override val perPackageOptions: List<PackageOptionsImpl> = emptyList(),
override val externalDocumentationLinks: Set<ExternalDocumentationLinkImpl> = emptySet(),
override val sourceLinks: Set<SourceLinkDefinitionImpl> = mutableSetOf(),
override val perPackageOptions: List<PackageOptionsImpl> = mutableListOf(),
override val externalDocumentationLinks: Set<ExternalDocumentationLinkImpl> = mutableSetOf(),
override val languageVersion: String? = null,
override val apiVersion: String? = null,
override val noStdlibLink: Boolean = DokkaDefaults.noStdlibLink,
Expand Down
2 changes: 1 addition & 1 deletion runners/cli/src/main/kotlin/cli/main.kt
Expand Up @@ -288,7 +288,7 @@ private fun parseSourceSet(moduleName: String, args: Array<String>): DokkaConfig
override val jdkVersion = jdkVersion
override val sourceLinks = sourceLinks.toMutableSet()
override val analysisPlatform = analysisPlatform
override val perPackageOptions = parsePerPackageOptions(perPackageOptions)
override val perPackageOptions = parsePerPackageOptions(perPackageOptions).toMutableList()
override val externalDocumentationLinks = parseLinks(externalDocumentationLinks).toMutableSet()
override val languageVersion = languageVersion
override val apiVersion = apiVersion
Expand Down
13 changes: 13 additions & 0 deletions runners/cli/src/test/kotlin/cli/CliTest.kt
Expand Up @@ -27,4 +27,17 @@ class CliIntegrationTest {

}

@Test
fun `should not fail when no sourceset options are specified`() {
val jsonPath = Paths.get(javaClass.getResource("/my-file-no-sourceset-options.json")?.toURI() ?: throw IllegalStateException("No JSON found!")).toFile().toString()
val globalArguments = GlobalArguments(arrayOf(jsonPath))

val configuration = initializeConfiguration(globalArguments)

configuration.sourceSets.forEach {
assertTrue(it.perPackageOptions.isEmpty())
assertTrue(it.sourceLinks.isEmpty())
assertTrue(it.externalDocumentationLinks.size == 2) // there are default values, java and kotlin stdlibs
}
}
}
13 changes: 13 additions & 0 deletions runners/cli/src/test/resources/my-file-no-sourceset-options.json
@@ -0,0 +1,13 @@
{
"outputDir": "build/docs",
"sourceSets": [
{
"moduleDisplayName": "Sample",
"sourceSetID": {
"scopeId": "sample",
"sourceSetName": "main"
},
"sourceRoots": ["sample"]
}
]
}