diff options
author | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2022-02-14 22:25:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 00:25:41 +0300 |
commit | b0244f69277f492eb87694cf34cc620a265adbcb (patch) | |
tree | a45bb3d754338feb3a4ba0faa7daf16a87b16434 /runners/cli/src | |
parent | 558c58b13d0b05537d1986696fb778cf30888f4b (diff) | |
download | dokka-b0244f69277f492eb87694cf34cc620a265adbcb.tar.gz dokka-b0244f69277f492eb87694cf34cc620a265adbcb.tar.bz2 dokka-b0244f69277f492eb87694cf34cc620a265adbcb.zip |
Fix loading empty properties by CLI json parser (#2362)
Diffstat (limited to 'runners/cli/src')
-rw-r--r-- | runners/cli/src/main/kotlin/cli/main.kt | 2 | ||||
-rw-r--r-- | runners/cli/src/test/kotlin/cli/CliTest.kt | 13 | ||||
-rw-r--r-- | runners/cli/src/test/resources/my-file-no-sourceset-options.json | 13 |
3 files changed, 27 insertions, 1 deletions
diff --git a/runners/cli/src/main/kotlin/cli/main.kt b/runners/cli/src/main/kotlin/cli/main.kt index 4768828b..c2a68d68 100644 --- a/runners/cli/src/main/kotlin/cli/main.kt +++ b/runners/cli/src/main/kotlin/cli/main.kt @@ -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 diff --git a/runners/cli/src/test/kotlin/cli/CliTest.kt b/runners/cli/src/test/kotlin/cli/CliTest.kt index 5910e938..967003dc 100644 --- a/runners/cli/src/test/kotlin/cli/CliTest.kt +++ b/runners/cli/src/test/kotlin/cli/CliTest.kt @@ -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 + } + } } diff --git a/runners/cli/src/test/resources/my-file-no-sourceset-options.json b/runners/cli/src/test/resources/my-file-no-sourceset-options.json new file mode 100644 index 00000000..3a8643d1 --- /dev/null +++ b/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"] + } + ] +} |