Kotlin / dokka

API documentation engine for Kotlin
https://kotl.in/dokka
Apache License 2.0
3.42k stars 405 forks source link

Gradle: templates dir contents do not affect dokka task up-to-date status #2885

Open ilya-g opened 1 year ago

ilya-g commented 1 year ago

Describe the bug Changing content in templates directory doesn't make Dokka tasks that use these templates outdated and the documentation isn't rebuilt. It looks like the path to templates directory is being snapshotted as a plain string property

Expected behaviour Templates directory is treated as an input directory, so its content is snapshotted.

Dokka configuration Configuration of dokka used to reproduce the bug

    tasks.register<DokkaTaskPartial>("dokka") {
        with(pluginsMapConfiguration) {
            put("org.jetbrains.dokka.base.DokkaBase"                      , """{ "templatesDir": "$templatesDir" }""")
            put("org.jetbrains.dokka.versioning.VersioningPlugin"         , """{ "version": "$version" }" }""")
        }
    }

Installation

aSemy commented 1 year ago

For reference, I've tried to resolve this in Dokkatoo. It wasn't easy!

I defined a 'base' plugin config class. Subclasses (e.g. DokkaHtmlPluginParameters) have the correct Gradle input annotations.

In the Dokkatoo extension I created a container that holds the configuration for each plugin

https://github.com/adamko-dev/dokkatoo/blob/718b4311da6cfcd255b7d1d22115ad1e64e970ba/modules/dokkatoo-plugin/src/main/kotlin/DokkatooExtension.kt#L89-L95

This same container is also passed into the appropriate Task, and marked as @Nested so the inputs of the plugin configs would be recognised by Gradle.

https://github.com/adamko-dev/dokkatoo/blob/718b4311da6cfcd255b7d1d22115ad1e64e970ba/modules/dokkatoo-plugin/src/main/kotlin/tasks/DokkatooPrepareParametersTask.kt#L35-L40