diff options
Diffstat (limited to 'runners')
-rw-r--r-- | runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt | 9 | ||||
-rw-r--r-- | runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt (renamed from runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt) | 5 | ||||
-rw-r--r-- | runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt | 68 |
3 files changed, 74 insertions, 8 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt index 84f35cb4..bed73d6d 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt @@ -17,7 +17,6 @@ import org.jetbrains.dokka.DokkaDefaults import org.jetbrains.dokka.DokkaSourceSetID import org.jetbrains.dokka.Platform import java.io.File -import java.io.Serializable import java.net.URL import java.util.concurrent.Callable import kotlin.reflect.KMutableProperty @@ -25,7 +24,7 @@ import kotlin.reflect.full.memberProperties import org.gradle.api.tasks.SourceSet as GradleSourceSet import org.jetbrains.kotlin.gradle.model.SourceSet as KotlinSourceSet -class GradleSourceRootImpl : SourceRoot, Serializable { +class GradleSourceRootImpl : SourceRoot { override var path: String = "" set(value) { field = File(value).absolutePath @@ -208,13 +207,13 @@ fun GradleDokkaSourceSet.dependsOn(sourceSet: AndroidSourceSet) { dependsOn(DokkaSourceSetID(sourceSet.name)) } -class GradleSourceLinkDefinitionImpl : SourceLinkDefinition, Serializable { +class GradleSourceLinkDefinitionImpl : SourceLinkDefinition { override var path: String = "" override var url: String = "" override var lineSuffix: String? = null } -class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink, Serializable { +class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink { override var url: URL = URL("http://") override var packageListUrl: URL = URL("http://") } @@ -236,7 +235,7 @@ class GradleDokkaConfigurationImpl : DokkaConfiguration { override var modules: List<GradleDokkaModuleDescription> = emptyList() } -class GradlePackageOptionsImpl : PackageOptions, Serializable { +class GradlePackageOptionsImpl : PackageOptions { override var prefix: String = "" override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented 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/DokkaConfigurationJsonTest.kt index b6cf2119..d80f43e4 100644 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/GradleDokkaConfigurationJsonTest.kt +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt @@ -1,6 +1,5 @@ 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.* @@ -8,7 +7,7 @@ import java.net.URL import kotlin.test.Test import kotlin.test.assertEquals -class GradleDokkaConfigurationJsonTest { +class DokkaConfigurationJsonTest { @Test fun `DokkaTask configuration toJsonString then parseJson`() { @@ -35,7 +34,7 @@ class GradleDokkaConfigurationJsonTest { link.url = URL("http://some.other.url") } sourceSet.collectKotlinTasks = { - println(this@GradleDokkaConfigurationJsonTest) + println(this@DokkaConfigurationJsonTest) println("This lambda is capturing the entire test") emptyList() } 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 new file mode 100644 index 00000000..70ecfcf0 --- /dev/null +++ b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt @@ -0,0 +1,68 @@ +package org.jetbrains.dokka.gradle + +import org.gradle.kotlin.dsl.withType +import org.gradle.testfixtures.ProjectBuilder +import org.jetbrains.dokka.DokkaConfiguration +import org.jetbrains.dokka.toJsonString +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import java.io.ObjectInputStream +import java.io.ObjectOutputStream +import java.net.URL +import kotlin.test.Test +import kotlin.test.assertEquals + +class DokkaConfigurationSerializableTest { + + @get:Rule + val temporaryFolder = TemporaryFolder() + + @Test + fun `DokkaTask configuration write to file then parse`() { + 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 = { + emptyList() + } + + sourceSet.perPackageOption { packageOption -> + packageOption.includeNonPublic = true + packageOption.reportUndocumented = true + packageOption.skipDeprecated = true + } + } + } + + val sourceConfiguration = dokkaTask.getConfigurationOrThrow() + val configurationFile = temporaryFolder.root.resolve("config.bin") + ObjectOutputStream(configurationFile.outputStream()).use { stream -> + stream.writeObject(sourceConfiguration) + } + val parsedConfiguration = ObjectInputStream(configurationFile.inputStream()).use { stream -> + stream.readObject() as DokkaConfiguration + } + + /* Abusing toJsonString, since there is no proper .equals on the gradle implementations yet */ + assertEquals(sourceConfiguration.toJsonString(), parsedConfiguration.toJsonString()) + } +} |