diff options
| author | Ignat Beresnev <ignat.beresnev@jetbrains.com> | 2023-11-10 11:46:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-10 11:46:54 +0100 |
| commit | 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch) | |
| tree | 1b915207b2b9f61951ddbf0ff2e687efd053d555 /runners/gradle-plugin/src/test | |
| parent | a44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff) | |
| download | dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2 dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip | |
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing
* Update Gradle to 8.4
* Refactor and simplify convention plugins and build scripts
Fixes #3132
---------
Co-authored-by: Adam <897017+aSemy@users.noreply.github.com>
Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'runners/gradle-plugin/src/test')
18 files changed, 0 insertions, 2443 deletions
diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt deleted file mode 100644 index 02b7a0f9..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AbstractDokkaParentTaskTest.kt +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -@file:Suppress("DEPRECATION") - -package org.jetbrains.dokka.gradle - -import org.gradle.api.Project -import org.gradle.kotlin.dsl.create -import org.gradle.kotlin.dsl.getByName -import org.gradle.testfixtures.ProjectBuilder -import org.jetbrains.dokka.DokkaConfigurationImpl -import org.jetbrains.dokka.gradle.utils.subprojects_ -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith - -class AbstractDokkaParentTaskTest { - - private val rootProject = ProjectBuilder.builder().build() - private val subproject0 = ProjectBuilder.builder().withName("subproject0").withParent(rootProject).build() - private val subproject1 = ProjectBuilder.builder().withName("subproject1").withParent(rootProject).build() - private val subSubproject0 = ProjectBuilder.builder().withName("subSubproject0").withParent(subproject0).build() - - init { - rootProject.subprojects_ { - tasks.create<DokkaTask>("dokkaTask") - } - } - - private val parentTask = rootProject.tasks.create<TestDokkaParentTask>("parent") - - - @Test - fun `add and remove tasks by reference`() { - assertEquals( - emptySet(), parentTask.childDokkaTasks, - "Expected no childDokkaTasks by default" - ) - - parentTask.addChildTask(subproject0.dokkaTask) - assertEquals( - setOf(subproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} being registered as child task" - ) - - parentTask.addChildTask(subproject1.dokkaTask) - assertEquals( - setOf(subproject0.dokkaTask, subproject1.dokkaTask), parentTask.childDokkaTasks, - "Expected both dokka tasks being present" - ) - - parentTask.removeChildTask(subproject0.dokkaTask) - assertEquals( - setOf(subproject1.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} being removed from child tasks" - ) - - parentTask.addChildTask(subSubproject0.dokkaTask) - assertEquals( - setOf(subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subSubproject0.dokkaTask.path} being added as child task" - ) - - parentTask.addChildTask(subSubproject0.dokkaTask) - assertEquals( - setOf(subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected no effect for adding a task twice" - ) - } - - @Test - fun `add and remove by absolute path`() { - parentTask.addChildTask(":subproject0:dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} as child task" - ) - - parentTask.addChildTask(":subproject0:subSubproject0:dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subSubproject0.dokkaTask.path} being added as child task" - ) - - parentTask.removeChildTask(":subproject0:dokkaTask") - assertEquals( - setOf(subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} being removed as child task" - ) - } - - @Test - fun `add and remove by relative path`() { - parentTask.addChildTask("subproject0:dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} as child task" - ) - - parentTask.addChildTask("subproject0:subSubproject0:dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subSubproject0.dokkaTask.path} being added as child task" - ) - - parentTask.removeChildTask("subproject0:dokkaTask") - assertEquals( - setOf(subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} being removed as child task" - ) - } - - @Test - fun `add and remove by relative path ob subproject0`() { - val parentTask = subproject0.tasks.create<TestDokkaParentTask>("parent") - - parentTask.addChildTask("subSubproject0:dokkaTask") - assertEquals( - setOf(subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subSubproject0.dokkaTask.path} being registered as child" - ) - - parentTask.removeChildTask("subSubproject0:dokkaTask") - assertEquals( - emptySet(), parentTask.childDokkaTasks, - "Expected ${subSubproject0.dokkaTask.path} being removed as child" - ) - } - - @Test - fun `add and remove by project and name`() { - parentTask.addChildTasks(rootProject.subprojects, "dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask, subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected all subproject tasks being registered as child task" - ) - - parentTask.removeChildTasks(rootProject.subprojects, "dokkaTask") - assertEquals( - emptySet(), parentTask.childDokkaTasks, - "Expected all tasks being removed" - ) - - parentTask.addChildTasks(listOf(subproject0), "dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected only ${subproject0.dokkaTask.path} being registered as child" - ) - - parentTask.addSubprojectChildTasks("dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask, subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected all subproject tasks being registered as child task" - ) - - parentTask.removeSubprojectChildTasks("dokkaTask") - assertEquals( - emptySet(), parentTask.childDokkaTasks, - "Expected all tasks being removed" - ) - - parentTask.addSubprojectChildTasks("dokkaTask") - assertEquals( - setOf(subproject0.dokkaTask, subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected all subproject tasks being registered as child task" - ) - - parentTask.removeChildTasks(subproject0) - assertEquals( - setOf(subproject1.dokkaTask, subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected only ${subproject0.dokkaTask.path} being removed" - ) - - parentTask.addSubprojectChildTasks("dokkaTask") - parentTask.removeChildTasks(listOf(subproject0, subproject1)) - assertEquals( - setOf(subSubproject0.dokkaTask), parentTask.childDokkaTasks, - "Expected ${subproject0.dokkaTask.path} and ${subproject1.dokkaTask.path} being removed" - ) - } - - @Test - fun `adding invalid path will not throw exception`() { - parentTask.addChildTask(":some:stupid:path") - parentTask.childDokkaTasks - } - - @Test - fun `adding non dokka task will throw exception`() { - val badTask = rootProject.tasks.create("badTask") - parentTask.addChildTask(badTask.path) - assertFailsWith<IllegalArgumentException> { parentTask.childDokkaTasks } - } -} - -internal abstract class TestDokkaParentTask : AbstractDokkaParentTask() { - override fun buildDokkaConfiguration(): DokkaConfigurationImpl { - throw NotImplementedError() - } -} - -private val Project.dokkaTask: DokkaTask get() = tasks.getByName<DokkaTask>("dokkaTask") diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt deleted file mode 100644 index 8e00c96c..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AndroidAutoConfigurationTest.kt +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gradle - -import com.android.build.gradle.LibraryExtension -import org.gradle.api.artifacts.ResolveException -import org.gradle.api.internal.project.ProjectInternal -import org.gradle.kotlin.dsl.configure -import org.gradle.kotlin.dsl.withType -import org.gradle.testfixtures.ProjectBuilder -import kotlin.test.* - -class AndroidAutoConfigurationTest { - - private val project = ProjectBuilder.builder().build().also { project -> - project.plugins.apply("com.android.library") - project.plugins.apply("org.jetbrains.kotlin.android") - project.plugins.apply("org.jetbrains.dokka") - project.extensions.configure<LibraryExtension> { - compileSdkVersion(28) - } - } - - @Test - fun `at least one dokka task created`() { - val dokkaTasks = project.tasks.withType<DokkaTask>().toList() - assertTrue(dokkaTasks.isNotEmpty(), "Expected at least one dokka task") - } - - @Test - fun `all default source sets are present in dokka`() { - val dokkaTasks = project.tasks.withType<DokkaTask>().toList() - dokkaTasks.forEach { task -> - val sourceSets = task.dokkaSourceSets.toList() - assertEquals( - listOf( - "androidTest", "androidTestDebug", "debug", "main", - "release", "test", "testDebug", "testRelease", "androidTestRelease" - ).sorted(), - sourceSets.map { it.name }.sorted(), - "Expected all default source sets being registered" - ) - } - } - - @Test - fun `test source sets are suppressed`() { - val dokkaTasks = project.tasks.withType<DokkaTask>().toList() - project as ProjectInternal - project.evaluate() - dokkaTasks.flatMap { it.dokkaSourceSets }.forEach { sourceSet -> - if ("test" in sourceSet.name.toLowerCase()) { - assertTrue( - sourceSet.suppress.get(), - "Expected source set `${sourceSet.name}` to be suppressed by default" - ) - } else { - assertFalse( - sourceSet.suppress.get(), - "Expected source set `${sourceSet.name}`to not be suppressed by default" - ) - } - } - } - - @Test - fun `source sets have non-empty classpath`() { - val dokkaTasks = project.tasks.withType<DokkaTask>().toList() - project as ProjectInternal - project.evaluate() - - dokkaTasks.flatMap { it.dokkaSourceSets } - .filterNot { it.name == "androidTestRelease" && it.suppress.get() } // androidTestRelease has empty classpath, but it makes no sense for suppressed source set - .forEach { sourceSet -> - /* - - There is no better way of checking for empty classpath at the moment (without resolving dependencies). - We assume, that an empty classpath can be resolved - We assume, that a non-empty classpath will not be able to resolve (no repositories defined) - */ - assertFailsWith<ResolveException>("SourceSet: " + sourceSet.name) { sourceSet.classpath.files } - } - } -} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt deleted file mode 100644 index c8f58f27..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/AutomagicProxyTest.kt +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gradle - -import org.jetbrains.dokka.DokkaBootstrap -import org.jetbrains.dokka.gradle.AutomagicProxyTest.TestInterface -import java.util.function.BiConsumer -import kotlin.test.Test -import kotlin.test.assertEquals -import kotlin.test.assertFailsWith - - -class AutomagicProxyTest { - - private class TestException(message: String, cause: Throwable?) : Exception(message, cause) - - private fun interface TestInterface { - @Throws(Throwable::class) - operator fun invoke(): Int - } - - @Test - fun `simple method invocation`() { - val instance = TestInterface { 0 } - val proxy = automagicTypedProxy<TestInterface>(instance.javaClass.classLoader, instance) - assertEquals(0, proxy()) - } - - @Test - fun `exception throw in DokkaBootstrap is not wrapped inside UndeclaredThrowableException`() { - val instanceThrowingTestException = object : DokkaBootstrap { - override fun configure(serializedConfigurationJSON: String, logger: BiConsumer<String, String>) = Unit - override fun generate() { - throw TestException("Test Exception Message", Exception("Cause Exception Message")) - } - } - - val proxy = automagicTypedProxy<DokkaBootstrap>( - instanceThrowingTestException.javaClass.classLoader, - instanceThrowingTestException - ) - - val exception = assertFailsWith<TestException> { - proxy.generate() - } - - assertEquals("Test Exception Message", exception.message) - assertEquals("Cause Exception Message", exception.cause?.message) - } -} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt deleted file mode 100644 index 92adc0e5..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/CheckSourceSetDependenciesTest.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gradle - -import org.gradle.testfixtures.ProjectBuilder -import java.lang.IllegalArgumentException -import kotlin.test.Test -import kotlin.test.assertFailsWith -import kotlin.test.assertTrue - -class CheckSourceSetDependenciesTest { - - private val project = ProjectBuilder.builder().build() - - @Test - fun `passes when properly configured`() { - val sourceSets = listOf( - GradleDokkaSourceSetBuilder("common", project), - GradleDokkaSourceSetBuilder("jvmAndJsCommon", project).apply { - dependsOn("common") - }, - GradleDokkaSourceSetBuilder("jvm", project).apply { - dependsOn("jvmAndJsCommon") - }, - GradleDokkaSourceSetBuilder("js", project).apply { - dependsOn("jvmAndJsCommon") - } - ) - checkSourceSetDependencies(sourceSets) - } - - @Test - fun `throws exception when dependent source set id cant be found`() { - val sourceSets = listOf( - GradleDokkaSourceSetBuilder("main", project), - GradleDokkaSourceSetBuilder("bad", project).apply { - dependsOn("missing") - } - ) - - val exception = assertFailsWith<IllegalArgumentException> { - checkSourceSetDependencies(sourceSets) - } - - assertTrue("bad" in exception.message.orEmpty(), "Expected name of source set mentioned") - assertTrue("missing" in exception.message.orEmpty(), "Expected name of missing source set mentioned") - } - - @Test - fun `throws exception when documented source set depends on suppressed source set`() { - val sourceSets = listOf( - GradleDokkaSourceSetBuilder("common", project), - GradleDokkaSourceSetBuilder("intermediate", project).apply { - dependsOn("common") - suppress.set(true) - }, - GradleDokkaSourceSetBuilder("jvm", project).apply { - dependsOn("intermediate") - } - ) - - val exception = assertFailsWith<IllegalArgumentException> { - checkSourceSetDependencies(sourceSets) - } - - assertTrue("intermediate" in exception.message.orEmpty()) - assertTrue("jvm" in exception.message.orEmpty()) - } -} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt deleted file mode 100644 index 55acbf2f..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/ConfigureWithKotlinSourceSetGistTest.kt +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.gradle - -import org.gradle.api.artifacts.FileCollectionDependency -import org.gradle.kotlin.dsl.get -import org.gradle.testfixtures.ProjectBuilder -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.gradle.kotlin.KotlinSourceSetGist -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension -import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType -import kotlin.test.Test -import kotlin.test.assertEquals -import org.jetbrains.dokka.gradle.utils.withDependencies_ -import kotlin.test.assertTrue - -class ConfigureWithKotlinSourceSetGistTest { - @Test - fun `example gist`() { - val project = ProjectBuilder.builder().build() - - val f1Jar = project.file("f1.jar") - val f2Jar = project.file("f2.jar") - assertTrue(f1Jar.createNewFile()) - assertTrue(f2Jar.createNewFile()) - - val customSourceRoot = project.file("customSourceRoot") - assertTrue(customSourceRoot.mkdirs()) - - val gist = KotlinSourceSetGist( - name = "customName", - platform = project.provider { KotlinPlatformType.common }, - isMain = project.provider { true }, - classpath = project.provider { project.files(f1Jar, f2Jar) }, - sourceRoots = project.files(customSourceRoot), - dependentSourceSetNames = project.provider { setOf("customRootSourceSet") } - ) - - val sourceSet = GradleDokkaSourceSetBuilder("", project) - sourceSet.configureWithKotlinSourceSetGist(gist) - - assertEquals( - "common", sourceSet.build().displayName, - "Expected platform being used as default displayName for source set" - ) - - assertEquals( - Platform.common, sourceSet.build().analysisPlatform, - "Expected common platform being set" - ) - - assertEquals( - listOf(f1Jar, f2Jar), sourceSet.build().classpath, - "Expected classpath being present" - ) - - assertEquals( - setOf(sourceSet.DokkaSourceSetID("customRootSourceSet")), sourceSet.build().dependentSourceSets, - "Expected customRootSourceSet being present in dependentSourceSets after build" - ) - - assertEquals( - setOf(customSourceRoot), sourceSet.build().sourceRoots, - "Expected customSourceRoot being present in sourceRoots after build" - ) - } - - @Test - fun `display name for source set customMain`() { - val project = ProjectBuilder.builder().build() - - val gist = KotlinSourceSetGist( - name = "customMain", - platform = project.provider { KotlinPlatformType.common }, - isMain = project.provider { true }, - classpath = project.provider { project.files() }, - sourceRoots = project.files(), - dependentSourceSetNames = project.provider { emptySet() } - ) - - val sourceSet = GradleDokkaSourceSetBuilder("", project) - sourceSet.configureWithKotlinSourceSetGist(gist) - - assertEquals( - "custom", sourceSet.build().displayName, - "Expected 'Main' being trimmed from source set name and used as display name" - ) - } - - @Suppress("UnstableApiUsage") - @Test - fun `configuration with kotlin source set is live`() { - val project = ProjectBuilder.builder().build() - project.plugins.apply("org.jetbrains.kotlin.jvm") - val kotlin = project.kotlin as KotlinJvmProjectExtension - val mainSourceSet = kotlin.sourceSets["main"] - - /* Make sure that the source roots exist on filesystem */ - mainSourceSet.kotlin.sourceDirectories.elements.get().map { it.asFile }.forEach { it.mkdirs() } - - /* Make sure to remove dependencies that cannot be resolved during test */ - project.configurations.configureEach { - withDependencies_ { - removeIf { dependency -> dependency !is FileCollectionDependency } - } - } - - val dokkaSourceSet = GradleDokkaSourceSetBuilder("main", project) - dokkaSourceSet.kotlinSourceSet(mainSourceSet) - - assertEquals( - listOf(project.file("src/main/kotlin"), project.file("src/main/java")), - dokkaSourceSet.sourceRoots.elements.get().map { it.asFile }, - "Expected default source roots being present in dokkaSourceSet" - ) - - val customSourceRoot = project.file("src/main/customRoot") - assertTrue(customSourceRoot.mkdirs()) - mainSourceSet.kotlin.srcDir(customSourceRoot) - - assertEquals( - listOf(project.file("src/main/kotlin"), project.file("src/main/java"), project.file("src/main/customRoot")), - dokkaSourceSet.sourceRoots.elements.get().map { it.asFile }, - "Expected customRoot being added to source roots in dokkaSourceSet" - ) - } - - @Test - fun `changing classpath`() { - val project = ProjectBuilder.builder().build() - val dokkaSourceSet = GradleDokkaSourceSetBuilder("main", project) - var classpath = project.files() - - dokkaSourceSet.configureWithKotlinSourceSetGist( - KotlinSourceSetGist( - name = "gist", - platform = project.provider { KotlinPlatformType.common }, - isMain = project.provider { true }, - dependentSourceSetNames = project.provider { emptySet() }, - sourceRoots = project.files(), - classpath = project.provider { classpath } - ) - ) - - dokkaSourceSet.classpath.from("base.jar") - classpath.from("f1.jar") - classpath.from("f2.jar") - assertEquals( - setOf(project.file("f1.jar"), project.file("f2.jar"), project.file("base.jar")), - dokkaSourceSet.classpath.files, - "Expected files from initial gist classpath and manually added file base.jar to be present in classpath" - ) - - /* - Swapping the original file collection in favour of a new one. - We expect that the base.jar is still present, as it was configured on the dokka source set. - We also expect, that the new files from the new file collection are replacing old ones - */ - classpath = project.files("f3.jar", "f4.jar") - assertEquals( - setOf(project.file("f3.jar"), project.file("f4.jar"), project.file("base.jar")), - dokkaSourceSet.classpath.files, - "Expected files from changed gist classpath and manually added file base.jar to be present in classpath" - ) - } - - -} diff --git a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt b/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt deleted file mode 100644 index c2a05eb5..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationJsonTest.kt +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -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.DokkaConfigurationImpl -import org.jetbrains.dokka.PluginConfigurationImpl -import org.jetbrains.dokka.gradle.utils.create_ -import org.jetbrains.dokka.gradle.utils.externalDocumentationLink_ -import org.jetbrains.dokka.gradle.utils.withDependencies_ -import org.jetbrains.dokka.toCompactJsonString -import java.io.File -import java.net.URL -import kotlin.test.Test -import kotlin.test.assertEquals - -class DokkaConfigurationJsonTest { - - @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_ { clear() } - dokkaTask.apply { - this.failOnWarning.set(true) - this.offlineMode.set(true) - this.outputDirectory.set(File("customOutputDir")) - this.cacheRoot.set(File("customCacheRoot")) - this.pluginsConfiguration.add( - PluginConfigurationImpl( - "A", - DokkaConfiguration.SerializationFormat.JSON, - """ { "key" : "value1" } """ - ) - ) - this.pluginsConfiguration.add( - PluginConfigurationImpl( - "B", - DokkaConfiguration.SerializationFormat.JSON, - """ { "key" : "value2" } """ - ) - ) - this.dokkaSourceSets.create_("main") { - displayName.set("customSourceSetDisplayName") - reportUndocumented.set(true) - - externalDocumentationLink_ { - packageListUrl.set(URL("http://some.url")) - url.set(URL("http://some.other.url")) - } - perPackageOption { - includeNonPublic.set(true) - reportUndocumented.set(true) - skipDeprecated.set(true) - documentedVisibilities.set(setOf(DokkaConfiguration.Visibility.PRIVATE)) - } - } - } - - val sourceConfiguration = dokkaTask.buildDokkaConfiguration() - val configurationJson = sourceConfiguration.toCompactJsonString() - val parsedConfiguration = DokkaConfigurationImpl(configurationJson) - - assertEquals(sourceConfiguration, parsedConfiguration) - println(parsedConfiguration) - } -} 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 deleted file mode 100644 index 02fd728b..00000000 --- a/runners/gradle-plugin/src/test/kotlin/org/jetbrains/dokka/gradle/DokkaConfigurationSerializableTest.kt +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -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.PluginConfigurationImpl -import org.jetbrains.dokka.gradle.utils.create_ -import org.jetbrains.dokka.gradle.utils.externalDocumentationLink_ -import org.jetbrains.dokka.gradle.utils.withDependencies_ -import org.junit.jupiter.api.io.TempDir -import java.io.File -import java.io.ObjectInputStream -import java.io.ObjectOutputStream -import java.net.URL -import kotlin.test.Test -import kotlin.test.assertEquals - -class DokkaConfigurationSerializableTest { - - @Test - fun `DokkaTask configuration write to file then parse`(@TempDir tempDirectory: File) { - val project = ProjectBuilder.builder().build() - project.plugins.apply("org.jetbrains.dokka") - val dokkaTask = project.tasks.withType<DokkaTask>().first() - dokkaTask.plugins.withDependencies_ { clear() } - dokkaTask.apply { - this.failOnWarning.set(true) - this.offlineMode.set(true) - this.outputDirectory.set(File("customOutputDir")) - this.cacheRoot.set(File("customCacheRoot")) - this.pluginsConfiguration.add( - PluginConfigurationImpl( - "A", - DokkaConfiguration.SerializationFormat.JSON, - """ { "key" : "value1" } """ - ) - ) - this.pluginsConfiguration.add( - PluginConfigurationImpl( - "B", - DokkaConfiguration.SerializationFormat.JSON, - """ { "key" : "value2" } """ - ) - ) - this.dokkaSourceSets.create_("main") { - displayName.set("customSourceSetDisplayName") - reportUndocumented.set(true) - - externalDocumentationLink_ { - packageListUrl.set(URL("http://some.url")) - url.set(URL("http://some.other.url")) - } - - perPackageOption { - includeNonPublic.set(true) - reportUndocumented.set(true) - skipDeprecated.set(true) - documentedVisibilities.set(setOf(DokkaConfiguration.Visibility.PRIVATE)) - } - } < |
