I am getting stuck when migrating from Dokka 2.0.0...
# dokka
a
I am getting stuck when migrating from Dokka 2.0.0 to 2.1.0. 🧵 Setup: • Android Kotlin multi-module project with Compose. • The individual modules seems to compile the versioning parts has stopped working. This is what used to work: proj level build.gradle.kts
Copy code
dependencies {
    dokka(project(":xxx:foundation:"))
    dokka(project(":xxx:design:"))
    dokka(project(":xxx:icons:"))
}

...

// Project level Dokka setup
pluginManager.withPlugin("org.jetbrains.dokka") {
    dokka {
        pluginsConfiguration.versioning {
            olderVersionsDir.set(layout.projectDirectory.dir("documentation/oldVersions"))
        }
        dokkaPublications.html {
            outputDirectory.set(layout.projectDirectory.dir("documentation/html"))
            includes.from("documentation/packages.md")
        }
    }
}

// Module level Dokka setup
allprojects {
val currentVersion = evaluateVersionName()
    val currentYear = Calendar.getInstance().get(Calendar.YEAR)
    pluginManager.withPlugin("org.jetbrains.dokka") {
        dokka {
            moduleName.set(project.name.replaceFirstChar { it.titlecase(Locale.getDefault()) }) // Capitalize first letter
            dokkaSourceSets.configureEach {
                includes.from("$projectDir/README.md")
                sourceLink {
                    basePublicationsDirectory
                    localDirectory.set(file("src/main/java"))
                    reportUndocumented.set(true) // Outputs to console if there are any undocumented elements
                    skipEmptyPackages.set(true)
                }
            }

            pluginsConfiguration.html {
                customAssets.from("${rootProject.rootDir}/documentation/logo-icon.svg")
            }

            pluginsConfiguration.versioning {
                version = currentVersion

                // If true, the dropdown with versions will be shown on all pages. Will increase compile build time.
                renderVersionsNavigationOnAllPages = true
            }
        }
}
Any ideas how to move forward? 🙏
Running
./gradlew dokkaGenerate
with the new version the versions dropdown disappears
I tried the approch from https://github.com/Kotlin/dokka/blob/master/dokka-subprojects/plugin-versioning/README.md#directory-structure but does not seem to do anything. Am I supposed to restructure anything else?
Copy code
tasks.dokkaHtml {
    // This can be any persistent folder where
    // you store documentation by version
    val docVersionsDir = projectDir.resolve("documentation/oldVersions")

    // The version for which you are currently generating docs
    val currentVersion = evaluateVersionName()

    // Set the output to a folder with all other versions
    // as you'll need the current version for future builds
    val currentDocsDir = docVersionsDir.resolve(currentVersion)
    outputDirectory.set(currentDocsDir)

    pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
        olderVersionsDir = docVersionsDir
        version = currentVersion
    }

    doLast {
        // This folder contains the latest documentation with all
        // previous versions included, so it's ready to be published.
        // Make sure it's copied and not moved - you'll still need this
        // version for future builds
        currentDocsDir.copyTo(projectDir.resolve("documentation/html"))

        // Only once current documentation has been safely moved,
        // remove previous versions bundled in it. They will not
        // be needed in future builds, it's just overhead.
//        currentDocsDir.resolve("older").deleteRecursively()
    }
}
o
Hey! There should be no changes to the versioning plugin in 2.1.0 vs 2.0.0 Could you take a look at the versioning example setup for DGPv2 and check what's different? So far, from your code examples, I don't see that you apply the
versioning
plugin in your
project config
like here. Overall, you need to configure
pluginsConfiguration.versioning
only for the aggregated project; it does nothing for separate modules.
👀 1
a
No I dont think that the changes between 2.0.0 and 2.1.0 are the problem. But in 2.1 the old solution has been scrapped so now I am forced to use the new solution. 🙂
👍 1
Thanks @Oleg Yukhnevich! 🙏 This did the trick
dokkaHtmlPlugin("org.jetbrains.dokka:versioning-plugin")
kodee happy 1
I was looking at this previously but wasnt get it to work. Is this part of the v1 solution or what am I missing? https://github.com/Kotlin/dokka/blob/master/dokka-subprojects/plugin-versioning/README.md#directory-structure @Oleg Yukhnevich
Specifically this section (and the more verbose example further down)
Copy code
import org.jetbrains.dokka.versioning.VersioningPlugin
import org.jetbrains.dokka.versioning.VersioningConfiguration

buildscript {
    dependencies {
        classpath("org.jetbrains.dokka:versioning-plugin:2.1.0")
    }
}

tasks.dokkaHtml {
    pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
        version = "1.5"
        versionsOrdering = listOf("1.5", "1.4", "1.3", "1.2", "1.1", "alpha-2", "alpha-1")
        olderVersionsDir = file("documentation/version")
        olderVersions = listOf(file("documentation/alpha/alpha-2"), file("documentation/alpha/alpha-1"))
        renderVersionsNavigationOnAllPages = true
    }
}
o
Is this part of the v1 solution or what am I missing?
Yes, this example is outdated... For now, the best way is to take a look on the example project configured with DGPv2, that I shared before We are currently in the process of updating the documentation on kotlinlang and will update readme's on GH after that
Specifically this section (and the more verbose example further down)
With DGPv2, versioning plugin now has type-safe DSL
a
Nice! Then I can get rid of the outdated code. Thanks.
kodee happy 1