diff --git a/build-logic/src/main/kotlin/dokkabuild.test-cli-dependencies.gradle.kts b/build-logic/src/main/kotlin/dokkabuild.test-cli-dependencies.gradle.kts new file mode 100644 index 0000000000..76c207efb2 --- /dev/null +++ b/build-logic/src/main/kotlin/dokkabuild.test-cli-dependencies.gradle.kts @@ -0,0 +1,45 @@ +/* +* Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. +*/ +import dokkabuild.utils.declarable +import dokkabuild.utils.resolvable +import org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE +import org.gradle.api.attributes.Bundling.SHADOWED +import org.gradle.api.attributes.Usage.JAVA_RUNTIME +import org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE + + +val dokkaCli: Configuration by configurations.creating { + description = "Dependency on Dokka CLI JAR. Must only contain a single dependency." + declarable() +} + +val dokkaCliResolver: Configuration by configurations.creating { + description = "Resolve the Dokka CLI JAR. Intransitive - must only contain a single JAR." + resolvable() + extendsFrom(dokkaCli) + attributes { + attribute(USAGE_ATTRIBUTE, objects.named(JAVA_RUNTIME)) + attribute(BUNDLING_ATTRIBUTE, objects.named(SHADOWED)) + } + // we should have single artifact here + isTransitive = false +} + + +val dokkaPluginsClasspath: Configuration by configurations.creating { + description = "Dokka CLI runtime dependencies required to run Dokka CLI, and its plugins." + declarable() +} + +val dokkaPluginsClasspathResolver: Configuration by configurations.creating { + description = "Resolve Dokka CLI runtime dependencies required to run Dokka CLI, and its plugins. " + + "Transitive dependencies are excluded, and so must be defined explicitly." + resolvable() + extendsFrom(dokkaPluginsClasspath) + attributes { + attribute(USAGE_ATTRIBUTE, objects.named(JAVA_RUNTIME)) + } + // we don't fetch transitive dependencies here to be able to control external dependencies explicitly + isTransitive = false +} diff --git a/dokka-integration-tests/cli/build.gradle.kts b/dokka-integration-tests/cli/build.gradle.kts index 7caa3569fe..11375f60c4 100644 --- a/dokka-integration-tests/cli/build.gradle.kts +++ b/dokka-integration-tests/cli/build.gradle.kts @@ -1,79 +1,89 @@ /* * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ +@file:Suppress("UnstableApiUsage") -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import org.gradle.api.attributes.Bundling.BUNDLING_ATTRIBUTE +import org.gradle.api.attributes.Bundling.SHADOWED plugins { - id("dokkabuild.test-integration") - id("com.github.johnrengelman.shadow") + id("dokkabuild.kotlin-jvm") + id("dokkabuild.test-cli-dependencies") + `jvm-test-suite` } dependencies { - implementation(kotlin("test-junit5")) - implementation(libs.junit.jupiterApi) - implementation(projects.utilities) -} + api(kotlin("test-junit5")) + api(libs.junit.jupiterApi) + api(projects.utilities) -val cliPluginsClasspath: Configuration by configurations.creating { - description = "plugins/dependencies required to run CLI with base plugin" - attributes { - attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME)) - } + dokkaCli("org.jetbrains.dokka:runner-cli") - // we don't fetch transitive dependencies here to be able to control external dependencies explicitly - isTransitive = false -} + //region required dependencies of plugin-base + dokkaPluginsClasspath("org.jetbrains.dokka:plugin-base") + dokkaPluginsClasspath(libs.kotlinx.html) + dokkaPluginsClasspath(libs.freemarker) -val cliClasspath: Configuration by configurations.creating { - description = "dependency on CLI JAR" - attributes { - attribute(Usage.USAGE_ATTRIBUTE, project.objects.named(Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED)) + val analysisDependency = dokkaBuild.integrationTestUseK2.map { useK2 -> + if (useK2) { + "org.jetbrains.dokka:analysis-kotlin-symbols" + } else { + "org.jetbrains.dokka:analysis-kotlin-descriptors" + } + } + dokkaPluginsClasspath(analysisDependency) { + attributes { + attribute(BUNDLING_ATTRIBUTE, project.objects.named(SHADOWED)) + } } - // we should have single artifact here - isTransitive = false + //endregion } -dependencies { - cliClasspath("org.jetbrains.dokka:runner-cli") - - cliPluginsClasspath("org.jetbrains.dokka:plugin-base") - // required dependencies of `plugin-base` - cliPluginsClasspath(libs.freemarker) - cliPluginsClasspath(libs.kotlinx.html) - - val tryK2 = project.providers - .gradleProperty("org.jetbrains.dokka.experimental.tryK2") - .map(String::toBoolean) - .orNull ?: false +/** + * Provide files required for running Dokka CLI in a build cache friendly way. + */ +abstract class DokkaCliClasspathProvider : CommandLineArgumentProvider { + @get:Classpath + abstract val dokkaCli: ConfigurableFileCollection - val analysisDependency = when { - tryK2 -> "org.jetbrains.dokka:analysis-kotlin-symbols" - else -> "org.jetbrains.dokka:analysis-kotlin-descriptors" - } + @get:Classpath + abstract val dokkaPluginsClasspath: ConfigurableFileCollection - cliPluginsClasspath(analysisDependency) { - attributes { - attribute(Bundling.BUNDLING_ATTRIBUTE, project.objects.named(Bundling.SHADOWED)) + override fun asArguments(): Iterable = buildList { + require(dokkaCli.count() == 1) { + "Expected a single Dokka CLI JAR, but got ${dokkaCli.count()}" } + add("-D" + "dokkaCliJarPath=" + dokkaCli.singleFile.absolutePath) + add("-D" + "dokkaPluginsClasspath=" + dokkaPluginsClasspath.joinToString(";") { it.absolutePath }) } } -val cliPluginsShadowJar by tasks.registering(ShadowJar::class) { - archiveFileName.set("cli-plugins-${project.version}.jar") - configurations = listOf(cliPluginsClasspath) - // service files are merged to make sure all Dokka plugins - // from the dependencies are loaded, and not just a single one. - mergeServiceFiles() -} +testing { + suites { + withType().configureEach { + useJUnitJupiter() + } -tasks.integrationTest { - dependsOn(cliClasspath) - dependsOn(cliPluginsShadowJar) + register("integrationTest") { + dependencies { + implementation(project()) + } + + targets.configureEach { + testTask.configure { + jvmArgumentProviders.add( + objects.newInstance().apply { + dokkaCli.from(configurations.dokkaCliResolver) + dokkaPluginsClasspath.from(configurations.dokkaPluginsClasspathResolver) + } + ) + } + } + } + } +} - inputs.dir(file("projects")) - environment("CLI_JAR_PATH", cliClasspath.singleFile) - environment("BASE_PLUGIN_JAR_PATH", cliPluginsShadowJar.get().archiveFile.get()) +tasks.check { + dependsOn(testing.suites) } diff --git a/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt b/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt index b9c29dc57b..9a4caedf91 100644 --- a/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt +++ b/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/CliIntegrationTest.kt @@ -1,13 +1,10 @@ /* * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ - package org.jetbrains.dokka.it.cli import org.jetbrains.dokka.it.awaitProcessResult import java.io.File -import java.io.PrintWriter -import java.lang.IllegalStateException import kotlin.test.* class CliIntegrationTest : AbstractCliIntegrationTest() { @@ -20,7 +17,11 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { @Test fun runHelp() { - val process = ProcessBuilder("java", "-jar", cliJarFile.path, "-h") + val process = ProcessBuilder( + "java", + "-jar", dokkaCliJarPath, + "-h", + ) .redirectErrorStream(true) .start() @@ -34,9 +35,10 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-moduleName", "Basic Project", "-sourceSet", buildString { @@ -48,6 +50,7 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { append(" -skipDeprecated") } ) + .directory(projectDir) .redirectErrorStream(true) .start() @@ -109,9 +112,10 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-moduleName", "Basic Project", "-failOnWarning", "-sourceSet", @@ -137,9 +141,10 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-moduleName", "Basic Project", "-sourceSet", buildString { @@ -167,10 +172,11 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, "-loggingLevel", "DEBUG", - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-sourceSet", buildString { append(" -src ${File(projectDir, "src").path}") @@ -203,10 +209,11 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, "-loggingLevel", "WARN", - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-sourceSet", buildString { append(" -src ${File(projectDir, "src").path}") @@ -225,9 +232,10 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, + "java", + "-jar", dokkaCliJarPath, "-outputDir", dokkaOutputDir.path, - "-pluginsClasspath", basePluginJarFile.path, + "-pluginsClasspath", dokkaPluginsClasspath, "-moduleName", "Basic Project", "-sourceSet", buildString { @@ -266,20 +274,25 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { ) } - @Test fun `should accept json as input configuration`() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) - val resourcePath = javaClass.getResource("/my-file.json")?.toURI() ?: throw IllegalStateException("No JSON found!") - val jsonPath = File(resourcePath).absolutePath - PrintWriter(jsonPath).run { - write(jsonBuilder(dokkaOutputDir.invariantSeparatorsPath, basePluginJarFile.invariantSeparatorsPath, File(projectDir, "src").invariantSeparatorsPath, reportUndocumented = true)) - close() + val configJson = projectDir.resolve("dokka-config.json").apply { + writeText( + jsonBuilder( + outputPath = dokkaOutputDir.invariantSeparatorsPath, + pluginsClasspath = dokkaPluginsClasspath, + projectPath = File(projectDir, "src").invariantSeparatorsPath, + reportUndocumented = true + ) + ) } val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, jsonPath + "java", + "-jar", dokkaCliJarPath, + configJson.absolutePath, ).redirectErrorStream(true).start() val result = process.awaitProcessResult() @@ -304,55 +317,57 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { } /** - * This test disables global `reportUndocumneted` property and set `reportUndocumented` via perPackageOptions to + * This test disables global `reportUndocumented` property and set `reportUndocumented` via `perPackageOptions` to * make sure that global settings apply to dokka context. */ @Test fun `global settings should overwrite package options in configuration`() { val dokkaOutputDir = File(projectDir, "output") assertTrue(dokkaOutputDir.mkdirs()) - val resourcePath = javaClass.getResource("/my-file.json")?.toURI() ?: throw IllegalStateException("No JSON found!") - val jsonPath = File(resourcePath).absolutePath - PrintWriter(jsonPath).run { - write( + + val configJson = projectDir.resolve("dokka-config.json").apply { + writeText( jsonBuilder( outputPath = dokkaOutputDir.invariantSeparatorsPath, - pluginsClasspath = basePluginJarFile.invariantSeparatorsPath, + pluginsClasspath = dokkaPluginsClasspath, projectPath = File(projectDir, "src").invariantSeparatorsPath, globalSourceLinks = """ - { - "localDirectory": "/home/Vadim.Mishenev/dokka/examples/cli/src/main/kotlin", - "remoteUrl": "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-gradle-example/src/main/kotlin", - "remoteLineSuffix": "#L" - } - """.trimIndent(), - globalExternalDocumentationLinks = """ - { - "url": "https://docs.oracle.com/javase/8/docs/api/", - "packageListUrl": "https://docs.oracle.com/javase/8/docs/api/package-list" - }, - { - "url": "https://kotlinlang.org/api/latest/jvm/stdlib/", - "packageListUrl": "https://kotlinlang.org/api/latest/jvm/stdlib/package-list" - } + { + "localDirectory": "/home/Vadim.Mishenev/dokka/examples/cli/src/main/kotlin", + "remoteUrl": "https://github.com/Kotlin/dokka/tree/master/examples/gradle/dokka-gradle-example/src/main/kotlin", + "remoteLineSuffix": "#L" + } """.trimIndent(), + globalExternalDocumentationLinks = """ + { + "url": "https://docs.oracle.com/javase/8/docs/api/", + "packageListUrl": "https://docs.oracle.com/javase/8/docs/api/package-list" + }, + { + "url": "https://kotlinlang.org/api/latest/jvm/stdlib/", + "packageListUrl": "https://kotlinlang.org/api/latest/jvm/stdlib/package-list" + } + """.trimIndent(), globalPerPackageOptions = """ - { - "matchingRegex": ".*", - "skipDeprecated": "true", - "reportUndocumented": "true", - "documentedVisibilities": ["PUBLIC", "PRIVATE", "PROTECTED", "INTERNAL", "PACKAGE"] - } - """.trimIndent(), + { + "matchingRegex": ".*", + "skipDeprecated": "true", + "reportUndocumented": "true", + "documentedVisibilities": ["PUBLIC", "PRIVATE", "PROTECTED", "INTERNAL", "PACKAGE"] + } + """.trimIndent(), reportUndocumented = false - ), + ) ) - close() } val process = ProcessBuilder( - "java", "-jar", cliJarFile.path, jsonPath - ).redirectErrorStream(true).start() + "java", + "-jar", dokkaCliJarPath, + configJson.absolutePath, + ) + .redirectErrorStream(true) + .start() val result = process.awaitProcessResult() assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)") @@ -376,23 +391,24 @@ class CliIntegrationTest : AbstractCliIntegrationTest() { } @Test - fun `relative paths in configuraiton should work`() { - val resourcePath = - javaClass.getResource("/my-file.json")?.toURI() ?: throw IllegalStateException("No JSON found!") - val jsonPath = File(resourcePath) - + fun `relative paths in configuration should work`() { val dokkaOutputDir = File(projectDir, "output-relative") assertTrue(dokkaOutputDir.mkdirs()) - jsonPath.writeText( - jsonBuilder( - outputPath = dokkaOutputDir.invariantSeparatorsPath, - pluginsClasspath = basePluginJarFile.absoluteFile.invariantSeparatorsPath, - projectPath = "src", // relative path + + val configJson = projectDir.resolve("dokka-config.json").apply { + writeText( + jsonBuilder( + outputPath = dokkaOutputDir.invariantSeparatorsPath, + pluginsClasspath = dokkaPluginsClasspath, + projectPath = "src", // relative path + ) ) - ) + } ProcessBuilder( - "java", "-jar", cliJarFile.absolutePath, jsonPath.absolutePath + "java", + "-jar", dokkaCliJarPath, + configJson.absolutePath ).directory(projectDir).redirectErrorStream(true).start().also { process -> val result = process.awaitProcessResult() assertEquals(0, result.exitCode, "Expected exitCode 0 (Success)") diff --git a/dokka-integration-tests/cli/src/integrationTest/resources/my-file.json b/dokka-integration-tests/cli/src/integrationTest/resources/my-file.json deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/AbstractCliIntegrationTest.kt b/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/AbstractCliIntegrationTest.kt index 70c69753dd..14409663cc 100644 --- a/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/AbstractCliIntegrationTest.kt +++ b/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/AbstractCliIntegrationTest.kt @@ -1,40 +1,15 @@ /* * Copyright 2014-2024 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. */ - package org.jetbrains.dokka.it.cli import org.jetbrains.dokka.it.AbstractIntegrationTest -import java.io.File -import kotlin.test.BeforeTest -import kotlin.test.assertTrue +import org.jetbrains.dokka.it.systemProperty public abstract class AbstractCliIntegrationTest : AbstractIntegrationTest() { + /** The Dokka CLI JAR. */ + protected val dokkaCliJarPath: String by systemProperty() - protected val cliJarFile: File by lazy { - File(tempFolder, "dokka.jar") - } - - protected val basePluginJarFile: File by lazy { - File(tempFolder, "base-plugin.jar") - } - - @BeforeTest - public fun copyJarFiles() { - val cliJarPathEnvironmentKey = "CLI_JAR_PATH" - val cliJarFile = File(System.getenv(cliJarPathEnvironmentKey)) - assertTrue( - cliJarFile.exists() && cliJarFile.isFile, - "Missing path to CLI jar System.getenv($cliJarPathEnvironmentKey)" - ) - cliJarFile.copyTo(this.cliJarFile) - - val basePluginPathEnvironmentKey = "BASE_PLUGIN_JAR_PATH" - val basePluginJarFile = File(System.getenv(basePluginPathEnvironmentKey)) - assertTrue( - basePluginJarFile.exists() && basePluginJarFile.isFile, - "Missing path to base plugin jar System.getenv($basePluginPathEnvironmentKey)" - ) - basePluginJarFile.copyTo(this.basePluginJarFile) - } + /** Classpath required for running the Dokka CLI, delimited by `;`. */ + protected val dokkaPluginsClasspath: String by systemProperty() } diff --git a/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt b/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt similarity index 77% rename from dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt rename to dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt index 4ab894432a..a14cb462ca 100644 --- a/dokka-integration-tests/cli/src/integrationTest/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt +++ b/dokka-integration-tests/cli/src/main/kotlin/org/jetbrains/dokka/it/cli/jsonBuilder.kt @@ -4,21 +4,27 @@ package org.jetbrains.dokka.it.cli -fun jsonBuilder( +import org.intellij.lang.annotations.Language + +@Language("JSON") +public fun jsonBuilder( outputPath: String, pluginsClasspath: String, projectPath: String, + @Language("JSON", prefix = "[", suffix = "]") globalSourceLinks: String = "", + @Language("JSON", prefix = "[", suffix = "]") globalExternalDocumentationLinks: String = "", + @Language("JSON", prefix = "[", suffix = "]") globalPerPackageOptions: String = "", - reportUndocumented: Boolean = false - + reportUndocumented: Boolean = false, ): String { - return """{ + return """ +{ "moduleName": "Dokka Example", "moduleVersion": null, "outputDir": "$outputPath", - "pluginsClasspath": ["$pluginsClasspath"], + "pluginsClasspath": [${pluginsClasspath.split(";").joinToString(",") { "\"$it\"" }}], "cacheRoot": null, "offlineMode": false, "sourceLinks": [$globalSourceLinks], diff --git a/dokka-integration-tests/gradle/build.gradle.kts b/dokka-integration-tests/gradle/build.gradle.kts index 2e11f96538..541f0b545c 100644 --- a/dokka-integration-tests/gradle/build.gradle.kts +++ b/dokka-integration-tests/gradle/build.gradle.kts @@ -272,7 +272,7 @@ val testAllExternalProjects by tasks.registering { val integrationTest by tasks.registering { description = "Lifecycle task for running integration tests" - // TODO - Refactor Maven and CLI integration tests to use Test Suites + // TODO KT-64200 - Refactor Maven and CLI integration tests to use Test Suites // - Reimplement dokkabuild.test-integration.gradle.kts so that `integrationTest` is defined once there dependsOn(tasks.withType()) // all tests in this project are integration tests } diff --git a/dokka-integration-tests/settings.gradle.kts b/dokka-integration-tests/settings.gradle.kts index a490c21857..2c2a7e0398 100644 --- a/dokka-integration-tests/settings.gradle.kts +++ b/dokka-integration-tests/settings.gradle.kts @@ -41,7 +41,7 @@ dependencyResolutionManagement { includeBuild("../dokka-runners/runner-gradle-plugin-classic") includeBuild("../dokka-runners/runner-maven-plugin") includeBuild("../dokka-runners/runner-cli") -includeBuild("../.") // depend on the the root project, so integration-tests can depend on the `dokka-subprojects/*` subprojects and their artifacts +includeBuild("../.") // depend on the root project, so integration-tests can depend on projects in `dokka-subprojects/*` include( ":cli", diff --git a/dokka-integration-tests/utilities/build.gradle.kts b/dokka-integration-tests/utilities/build.gradle.kts index 8cb8d908e2..1787975cd0 100644 --- a/dokka-integration-tests/utilities/build.gradle.kts +++ b/dokka-integration-tests/utilities/build.gradle.kts @@ -13,7 +13,6 @@ dependencies { // thus these dependencies are needed. Ideally, they should be removed. implementation(kotlin("test-junit5")) - implementation(libs.kotlinx.coroutines.core) implementation(libs.jsoup) implementation(libs.eclipse.jgit) } diff --git a/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt b/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt index 23d3941d29..8ad8ec08e7 100644 --- a/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt +++ b/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/processUtils.kt @@ -4,52 +4,22 @@ package org.jetbrains.dokka.it -import kotlinx.coroutines.CompletableDeferred -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import kotlin.concurrent.thread +import java.util.concurrent.TimeUnit class ProcessResult( val exitCode: Int, val output: String ) -fun Process.awaitProcessResult(): ProcessResult = runBlocking { - val exitCode = async { awaitExitCode() } - val output = async { awaitOutput() } - ProcessResult( - exitCode.await(), - output.await() - ) -} - -private suspend fun Process.awaitExitCode(): Int { - val deferred = CompletableDeferred() - thread { - try { - deferred.complete(this.waitFor()) - } catch (e: Throwable) { - deferred.completeExceptionally(e) - } - } +fun Process.awaitProcessResult(): ProcessResult { + val output = inputStream.bufferedReader().lineSequence() + .onEach { println(it) } + .joinToString("\n") - return deferred.await() -} - -private suspend fun Process.awaitOutput(): String { - val deferred = CompletableDeferred() - thread { - try { - var string = "" - this.inputStream.bufferedReader().forEachLine { line -> - println(line) - string += line + System.lineSeparator() - } - deferred.complete(string) - } catch (e: Throwable) { - deferred.completeExceptionally(e) - } - } + waitFor(60, TimeUnit.SECONDS) - return deferred.await() + return ProcessResult( + exitCode = exitValue(), + output = output, + ) } diff --git a/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/systemProperties.kt b/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/systemProperties.kt index 24f43e52d4..74caf38078 100644 --- a/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/systemProperties.kt +++ b/dokka-integration-tests/utilities/src/main/kotlin/org/jetbrains/dokka/it/systemProperties.kt @@ -6,6 +6,14 @@ package org.jetbrains.dokka.it import kotlin.properties.ReadOnlyProperty +/** + * Delegated accessor for a system property. + * + * @see System.getProperty + */ +fun systemProperty(): ReadOnlyProperty = + systemProperty { it } + /** * Delegated accessor for a system property. * diff --git a/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt b/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt index 04757fae34..e69d6ea47d 100644 --- a/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt +++ b/dokka-runners/runner-cli/src/test/kotlin/org/jetbrains/dokka/CliTest.kt @@ -9,7 +9,7 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertTrue -class CliIntegrationTest { +class CliTest { @Test fun `should apply global settings to all source sets`() { diff --git a/dokka-subprojects/plugin-base/build.gradle.kts b/dokka-subprojects/plugin-base/build.gradle.kts index 753ee31eb3..58dc8d6764 100644 --- a/dokka-subprojects/plugin-base/build.gradle.kts +++ b/dokka-subprojects/plugin-base/build.gradle.kts @@ -55,11 +55,11 @@ dependencies { } } - // access the frontend files via the dependency on :plugins:base:frontend - val dokkaHtmlFrontendFiles: Provider = +// access the frontend files via the dependency on :plugins:base:frontend +val dokkaHtmlFrontendFiles: Provider = configurations.dokkaHtmlFrontendFiles.map { frontendFiles -> - frontendFiles.incoming.artifacts.artifactFiles - } + frontendFiles.incoming.artifacts.artifactFiles + } val prepareDokkaHtmlFrontendFiles by tasks.registering(Sync::class) { description = "copy Dokka Base frontend files into the resources directory"