diff --git a/CHANGELOG.md b/CHANGELOG.md index 56633ea8..6abe4e78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ ## 0.30.0 **UNRELEASED** +- Add support for Dokka 2.0.0-Beta + - Supports `org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled` + - Supports both `org.jetbrains.dokka` and `org.jetbrains.dokka-javadoc` + - If both are applied the javadoc output is published + - Removed support for the old `org.jetbrains.dokka-android` plugin - Remove usages of deprecated Gradle API that is scheduled to be removed in Gradle 9.0 - Raised minimum supported Gradle version @@ -23,7 +28,7 @@ Configuration cache is generally supported, except for: - Publishing releases to Maven Central (snapshots are fine), blocked by [Gradle issue #22779](https://github.com/gradle/gradle/issues/22779). -- Dokka does not support configuration cache +- When using Dokka until Dokka version 2.1.0 is out ## 0.29.0 *(2024-06-20)* diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt index 7a91f378..564ddccb 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/MavenPublishPluginSpecialCaseTest.kt @@ -252,4 +252,46 @@ class MavenPublishPluginSpecialCaseTest { assertThat(result).javadocJar().exists() assertThat(result).javadocJar().containsFiles(ignoreAdditionalFiles = true, "index.html") } + + @TestParameterInjectorTest + fun dokka2() { + val kotlinVersion = KotlinVersion.entries.last() + val original = kotlinJvmProjectSpec(kotlinVersion) + val project = original.copy( + plugins = original.plugins + dokka2Plugin, + basePluginConfig = original.basePluginConfig.replace("JavadocJar.Empty()", "JavadocJar.Dokka(\"dokkaGeneratePublicationHtml\")"), + ) + val result = project.run(fixtures, testProjectDir, testOptions) + + assertThat(result).outcome().succeeded() + assertThat(result).artifact("jar").exists() + assertThat(result).pom().exists() + assertThat(result).pom().matchesExpectedPom(kotlinStdlibJdk(kotlinVersion)) + assertThat(result).module().exists() + assertThat(result).sourcesJar().exists() + assertThat(result).sourcesJar().containsAllSourceFiles() + assertThat(result).javadocJar().exists() + assertThat(result).javadocJar().containsFiles(ignoreAdditionalFiles = true, "index.html") + } + + @TestParameterInjectorTest + fun dokka2Javadoc() { + val kotlinVersion = KotlinVersion.entries.last() + val original = kotlinJvmProjectSpec(kotlinVersion) + val project = original.copy( + plugins = original.plugins + dokka2JavadocPlugin, + basePluginConfig = original.basePluginConfig.replace("JavadocJar.Empty()", "JavadocJar.Dokka(\"dokkaGeneratePublicationJavadoc\")"), + ) + val result = project.run(fixtures, testProjectDir, testOptions) + + assertThat(result).outcome().succeeded() + assertThat(result).artifact("jar").exists() + assertThat(result).pom().exists() + assertThat(result).pom().matchesExpectedPom(kotlinStdlibJdk(kotlinVersion)) + assertThat(result).module().exists() + assertThat(result).sourcesJar().exists() + assertThat(result).sourcesJar().containsAllSourceFiles() + assertThat(result).javadocJar().exists() + assertThat(result).javadocJar().containsFiles(ignoreAdditionalFiles = true, "index.html") + } } diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt index 0d67013e..a46b76e0 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecRunner.kt @@ -20,7 +20,7 @@ fun ProjectSpec.run(fixtures: Path, temp: Path, options: TestOptions): ProjectRe val task = ":publishAllPublicationsToTestFolderRepository" val arguments = mutableListOf(task, "--stacktrace") - if (supportsConfigCaching(plugins)) { + if (supportsConfigCaching()) { arguments.add("--configuration-cache") } @@ -40,9 +40,10 @@ fun ProjectSpec.run(fixtures: Path, temp: Path, options: TestOptions): ProjectRe ) } -private fun supportsConfigCaching(plugins: List): Boolean { - // TODO https://github.com/Kotlin/dokka/issues/2231 - return !plugins.any { it.id == dokkaPlugin.id } +private fun ProjectSpec.supportsConfigCaching(): Boolean { + // TODO can always return true when dropping support for dokka in v1 mode + // to simplify the test set up this assumes that version 2.x always runs in v2 mode + return plugins.none { it.id == dokkaPlugin.id && it.version!!.startsWith("1.") } } private fun ProjectSpec.writeBuildFile(path: Path, repo: Path, options: TestOptions) { @@ -187,6 +188,8 @@ private fun ProjectSpec.writeGradleProperties(path: Path, options: TestOptions) appendLine("org.gradle.vfs.watch=false") appendLine("kotlin.compiler.execution.strategy=in-process") appendLine("kotlin.mpp.androidSourceSetLayoutVersion1.nowarn=true") + appendLine("org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled") + appendLine("org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true") appendLine() if (options.config == TestOptions.Config.PROPERTIES) { diff --git a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt index 0f2aee31..a1ce4240 100644 --- a/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt +++ b/plugin/src/integrationTest/kotlin/com/vanniktech/maven/publish/ProjectSpecs.kt @@ -15,6 +15,8 @@ val kotlinAndroidPlugin = PluginSpec("org.jetbrains.kotlin.android") val androidLibraryPlugin = PluginSpec("com.android.library") val gradlePluginPublishPlugin = PluginSpec("com.gradle.plugin-publish") val dokkaPlugin = PluginSpec("org.jetbrains.dokka", "1.8.10") +val dokka2Plugin = PluginSpec("org.jetbrains.dokka", "2.0.0-Beta") +val dokka2JavadocPlugin = PluginSpec("org.jetbrains.dokka-javadoc", "2.0.0-Beta") val fixtures = Paths.get("src/integrationTest/fixtures2").absolute() diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt index c38d8033..bb638488 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt @@ -406,12 +406,19 @@ abstract class MavenPublishBaseExtension @Inject constructor( private fun defaultJavaDocOption(javadocJar: Boolean, plainJavadocSupported: Boolean): JavadocJar { return if (!javadocJar) { JavadocJar.None() - } else if (project.plugins.hasPlugin("org.jetbrains.dokka") || project.plugins.hasPlugin("org.jetbrains.dokka-android")) { - val dokkaTask = project.provider { - val tasks = project.tasks.withType(DokkaTask::class.java) - tasks.singleOrNull()?.name ?: "dokkaHtml" + } else if (project.plugins.hasPlugin("org.jetbrains.dokka-javadoc")) { + JavadocJar.Dokka("dokkaGeneratePublicationJavadoc") + } else if (project.plugins.hasPlugin("org.jetbrains.dokka")) { + // only dokka v2 has an extension + if (project.extensions.findByName("dokka") != null) { + JavadocJar.Dokka("dokkaGeneratePublicationHtml") + } else { + val dokkaTask = project.provider { + val tasks = project.tasks.withType(DokkaTask::class.java) + tasks.singleOrNull()?.name ?: "dokkaHtml" + } + JavadocJar.Dokka(dokkaTask) } - JavadocJar.Dokka(dokkaTask) } else if (plainJavadocSupported) { project.tasks.withType(Javadoc::class.java).configureEach { val options = it.options as StandardJavadocDocletOptions