Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dokka 2.0 migration dokkaJavadoc issue #3988

Open
driessamyn opened this issue Jan 8, 2025 · 4 comments
Open

Dokka 2.0 migration dokkaJavadoc issue #3988

driessamyn opened this issue Jan 8, 2025 · 4 comments
Labels
bug runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131

Comments

@driessamyn
Copy link

Describe the bug
I am converting my project to Dokka 2, follwoing the documentation and running into a couple of issues.

gradle dokkaJavadoc executes succssfully but does not generate anything.

Adding

tasks.register<Jar>("dokkaJavadocJar") {
    dependsOn(tasks.dokkaJavadoc)
    from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
    archiveClassifier.set("javadoc")
}

as indicated in the docs here and running gradle dokkaJavadocJar gives the following error:

* What went wrong:
Execution failed for task ':kapper:dokkaJavadocJar'.
> Cannot query the value of this provider because it has no value available.
  The value of this provider is derived from:
    - task ':kapper:dokkaJavadoc' property 'outputDirectory'

The same error is produced for the dokkaHtmlJar example.

Expected behaviour

gradle dokkaJavadoc to generate javadocs
gradle dokkaJavadocJar to complete successfully.

To Reproduce

gradle dokkaJavadoc
gradle dokkaJavadocJar

Dokka configuration

id("org.jetbrains.dokka") version "2.0.0"
id("org.jetbrains.dokka-javadoc") version "2.0.0"

...

tasks.register<Jar>("dokkaHtmlJar") {
    dependsOn(tasks.dokkaHtml)
    from(tasks.dokkaHtml.flatMap { it.outputDirectory })
    archiveClassifier.set("html-docs")
}

tasks.register<Jar>("dokkaJavadocJar") {
    dependsOn(tasks.dokkaJavadoc)
    from(tasks.dokkaJavadoc.flatMap { it.outputDirectory })
    archiveClassifier.set("javadoc")
}

Installation

  • Operating system: macOS
  • Build tool: Gradle 8.12
  • Dokka version: 2.0.0
@driessamyn driessamyn added the bug label Jan 8, 2025
@vmishenev vmishenev added the runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131 label Jan 9, 2025
@driessamyn
Copy link
Author

FYI, full gradle file and project are here: https://github.com/driessamyn/kapper/blob/fix-dokka/lib/build.gradle.kts

@driessamyn
Copy link
Author

Any update on this or guidance on how v2 can be used?

It's a bit odd it was released as a stable version, but it's spewing warnings at me to upgrade with it doesn't seem like the V2 API (or docs) are complete?

@adam-enko
Copy link
Member

Hi @driessamyn, thanks for reporting the issue.

I've checked the Kapper project and I reproduced error you reported.

Fix

To collect the generated docs into a JAR use different tasks:

  • replace dokkaHtml with dokkaGeneratePublicationHtml
  • replace dokkaJavadoc with dokkaGeneratePublicationJavadoc
// lib/build.gradle.kts

// ...

tasks.register<Jar>("dokkaHtmlJar") {
    dependsOn(tasks.dokkaHtml)
    from(tasks.dokkaGeneratePublicationHtml.flatMap { it.outputDirectory })
    archiveClassifier.set("html-docs")
}

tasks.register<Jar>("dokkaJavadocJar") {
    dependsOn(tasks.dokkaJavadoc)
    from(tasks.dokkaGeneratePublicationJavadoc.flatMap { it.outputDirectory })
    archiveClassifier.set("javadoc")
}

After this I was able to run ./gradlew dokkaJavadocJar and produce the Javadoc JAR.

Image

Details

The tasks dokkaHtml and dokkaJavadoc are from DGPv1. Because Kapper has set the plugin mode to V2EnabledWithHelpers the DGPv1 tasks will still be present (to avoid buildscript compilation errors, which would make migration much more challenging), but are completely non-functional and will not do anything.

It's a bit odd it was released as a stable version, but it's spewing warnings at me to upgrade with it doesn't seem like the V2 API (or docs) are complete?

Please note that DGPv2 is experimental and is currently not stable.

At present there is an example demonstrating how to define the JAR tasks for Dokka HTML and Javadoc when using DPGv2 mode, but it is not yet referenced in the documentation. https://github.com/Kotlin/dokka/blob/v2.0.0/examples/gradle-v2/library-publishing-example/build.gradle.kts#L12-L22

When DGPv2 is released as stable we will update the docs to demonstrate how to produce the docs into JARs.

@driessamyn
Copy link
Author

Thanks @adam-enko .
This as very helpful and Kapper is now using the Dokka v2 API 👍

driessamyn/kapper#63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug runner: gradle plugin v2 Issues fixed by Dokka Gradle Plugin v2 - see https://github.com/Kotlin/dokka/issues/3131
Projects
None yet
Development

No branches or pull requests

3 participants