aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/test/kotlin
diff options
context:
space:
mode:
authorsebastian.sellmair <sebastian.sellmair@jetbrains.com>2020-07-16 10:24:02 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-07-20 12:02:45 +0200
commit13edb873db122e2088207ca10b94382e30875636 (patch)
tree44b90392faac5069848b27f6c5084dbca61607fe /runners/gradle-plugin/src/test/kotlin
parente7b50c6ba2102fc9a59a460172aa7a4d82ad08df (diff)
downloaddokka-13edb873db122e2088207ca10b94382e30875636.tar.gz
dokka-13edb873db122e2088207ca10b94382e30875636.tar.bz2
dokka-13edb873db122e2088207ca10b94382e30875636.zip
Use jackson for json serialization and parsing
Diffstat (limited to 'runners/gradle-plugin/src/test/kotlin')
-rw-r--r--runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt94
1 files changed, 94 insertions, 0 deletions
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt
new file mode 100644
index 00000000..b6cf2119
--- /dev/null
+++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt
@@ -0,0 +1,94 @@
+package org.jetbrains.dokka.gradle
+
+import org.gradle.api.artifacts.FileCollectionDependency
+import org.gradle.kotlin.dsl.withType
+import org.gradle.testfixtures.ProjectBuilder
+import org.jetbrains.dokka.*
+import java.net.URL
+import kotlin.test.Test
+import kotlin.test.assertEquals
+
+class GradleDokkaConfigurationJsonTest {
+
+ @Test
+ fun `DokkaTask configuration toJsonString then parseJson`() {
+ val project = ProjectBuilder.builder().build()
+ project.plugins.apply("org.jetbrains.dokka")
+ val dokkaTask = project.tasks.withType<DokkaTask>().first()
+ dokkaTask.plugins.withDependencies { dependencies ->
+ dependencies.clear()
+ }
+ dokkaTask.apply {
+ this.failOnWarning = true
+ this.offlineMode = true
+ this.outputDirectory = "customOutputDir"
+ this.cacheRoot = "customCacheRoot"
+ this.pluginsConfiguration["0"] = "a"
+ this.pluginsConfiguration["1"] = "b"
+ this.dokkaSourceSets.create("main") { sourceSet ->
+ sourceSet.moduleDisplayName = "moduleDisplayName"
+ sourceSet.displayName = "customSourceSetDisplayName"
+ sourceSet.reportUndocumented = true
+
+ sourceSet.externalDocumentationLink { link ->
+ link.packageListUrl = URL("http://some.url")
+ link.url = URL("http://some.other.url")
+ }
+ sourceSet.collectKotlinTasks = {
+ println(this@GradleDokkaConfigurationJsonTest)
+ println("This lambda is capturing the entire test")
+ emptyList()
+ }
+
+ sourceSet.perPackageOption { packageOption ->
+ packageOption.includeNonPublic = true
+ packageOption.reportUndocumented = true
+ packageOption.skipDeprecated = true
+ }
+ }
+ }
+
+ val sourceConfiguration = dokkaTask.getConfigurationOrThrow()
+ val configurationJson = sourceConfiguration.toJsonString()
+ val parsedConfiguration = DokkaConfigurationImpl(configurationJson)
+
+ assertEquals(
+ DokkaConfigurationImpl(
+ failOnWarning = sourceConfiguration.failOnWarning,
+ offlineMode = sourceConfiguration.offlineMode,
+ outputDir = sourceConfiguration.outputDir,
+ cacheRoot = sourceConfiguration.cacheRoot,
+ pluginsClasspath = emptyList(),
+ pluginsConfiguration = sourceConfiguration.pluginsConfiguration.toMap(),
+ sourceSets = listOf(
+ DokkaSourceSetImpl(
+ moduleDisplayName = sourceConfiguration.sourceSets.single().moduleDisplayName,
+ displayName = sourceConfiguration.sourceSets.single().displayName,
+ reportUndocumented = sourceConfiguration.sourceSets.single().reportUndocumented,
+ externalDocumentationLinks = sourceConfiguration.sourceSets.single().externalDocumentationLinks
+ .map { link ->
+ ExternalDocumentationLinkImpl(
+ url = link.url,
+ packageListUrl = link.packageListUrl
+ )
+ },
+ perPackageOptions = sourceConfiguration.sourceSets.single().perPackageOptions.map { option ->
+ PackageOptionsImpl(
+ prefix = option.prefix,
+ includeNonPublic = option.includeNonPublic,
+ reportUndocumented = option.reportUndocumented,
+ skipDeprecated = option.skipDeprecated,
+ suppress = option.suppress
+ )
+ },
+ sourceSetID = sourceConfiguration.sourceSets.single().sourceSetID,
+ sourceRoots = sourceConfiguration.sourceSets.single().sourceRoots.map { sourceRoot ->
+ SourceRootImpl(sourceRoot.path)
+ }
+ )
+ )
+ ), parsedConfiguration
+ )
+ println(parsedConfiguration)
+ }
+}