Skip to content

Commit

Permalink
Adjust the DGPv2 migration helpers to better support migration.
Browse files Browse the repository at this point in the history
- Create `dokka${Format}${Subtype}Plugin` (e.g. `dokkaHtmlMultiModulePlugin`) Configurations.
- Now that DGP has HTML and Javadoc plugins, adjust the deprecated `dokkaRuntime` Configuration to redirect to the 'base' `dokkaGeneratorRuntime` Configuration instead of the HTML-specific `dokkaHtmlGeneratorRuntime`.
  • Loading branch information
adam-enko committed Sep 17, 2024
1 parent 5e85c86 commit 5d0bfd8
Show file tree
Hide file tree
Showing 8 changed files with 2,444 additions and 4,993 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ private fun setupDokkaTasks(

/** @see org.jetbrains.dokka.gradle.maybeCreateDokkaPluginConfiguration */
fun ConfigurationContainer.createDokkaPluginConfiguration(taskName: String) {
if (createDokkaPluginFormatConfiguration) {
create("${taskName}Plugin") {
declarable()
deprecate(replaceWith = newConfs.pluginsClasspath)
}
create("${taskName}Plugin") {
declarable()
deprecate(replaceWith = newConfs.pluginsClasspath)
}
}

Expand All @@ -79,8 +77,11 @@ private fun setupDokkaTasks(
}
}

project.configurations.createDokkaPluginConfiguration(taskName = baseTaskName)
project.configurations.createDokkaRuntimeConfiguration(taskName = baseTaskName)
if (createDokkaPluginFormatConfiguration) {
// Don't create dokka${Format}Plugin Configurations, v2 will create Configurations with the same name and purpose.
project.configurations.createDokkaPluginConfiguration(taskName = baseTaskName)
project.configurations.createDokkaRuntimeConfiguration(taskName = baseTaskName)
}

project.tasks.register<DokkaTask>(baseTaskName) {
description = "$taskDesc Generates documentation in '$format' format."
Expand Down Expand Up @@ -119,7 +120,7 @@ private fun ConfigurationContainer.createDokkaDefaultRuntimeConfiguration(): Con
return create("dokkaRuntime") {
description = "[⚠ V1 Configurations are disabled] Classpath used to execute the Dokka Generator."
declarable()
deprecate(DependencyContainerNames("html").generatorClasspath)
deprecate(DependencyContainerNames("").generatorClasspath)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ import kotlin.test.assertEquals
class KotlinDslAccessorsTest : FunSpec({

context("Kotlin DSL generated accessors") {
val project = initMultiModuleProject("KotlinDslAccessorsTest")
val project = initMultiModuleProject("KotlinDslAccessorsTest") {
gradleProperties {
dokka {
v2Plugin = false
v2MigrationHelpers = false
}
}
}

/**
* Verify the current accessors match the dumped accessors.
Expand All @@ -41,11 +48,11 @@ class KotlinDslAccessorsTest : FunSpec({
) {
test("generated from project ${actualAccessors.projectPath} should match $expected") {

val expectedAccessors = resourceAsString(expected).trim()
val expectedAccessors = resourceAsString(expected)

assertEquals(
expected = expectedAccessors,
actual = actualAccessors.joined,
expected = expectedAccessors.trim(),
actual = actualAccessors.joined.trim(),
message = """
Task ${actualAccessors.projectPath} generated unexpected accessors.
Actual: ${actualAccessors.file.toUri()}
Expand Down Expand Up @@ -168,7 +175,8 @@ private class GeneratedDokkaAccessors(
val list: List<String>,
projectDir: Path,
) {
val joined: String = list.joinToString("\n\n")
val joined: String = list.joinToString(separator = "\n\n", postfix = "\n")

val file: Path = projectDir.resolve("dokka-accessors-${System.currentTimeMillis()}.txt").apply {
writeText(joined)
}
Expand Down Expand Up @@ -213,6 +221,7 @@ private fun GradleProjectTest.generateDokkaAccessors(
buildList {
add(org.gradle.util.Path.path(projectPath).relativePath("kotlinDslAccessorsReport").toString())
add("--quiet")
add("-Porg.jetbrains.dokka.experimental.gradlePlugin.enableV2=true")
enableV2MigrationHelpers?.let {
add("-Porg.jetbrains.dokka.experimental.gradlePlugin.enableV2MigrationHelpers=$it")
}
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 5d0bfd8

Please sign in to comment.