dokka: Fail to generate Javadoc with Java 10 (Doclet missing?)

When using Dokka 9.16 with JDK-10 the generation with outputFormat=javadoc fails with the following message:

* What went wrong:
Execution failed for task ':dokkaJavadoc'.
> com/sun/tools/doclets/formats/html/HtmlDoclet

I guess its due to the removal of the old HtmlDoclet in Java 10.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 56
  • Comments: 31 (8 by maintainers)

Commits related to this issue

Most upvoted comments

Still broken on Java 11

This effectively prevents one to build Kotlin JARs with JDK10+ and deploy them to Maven Central, since Maven Central requires javadoc artifacts (produced by Dokka). Huge blocker!

Yes, we still don’t support the new Doclet. This is planned for 0.11.0 to not develop this twice, as we changed the dokka internal model

@daviddenton i can confirm both javadoc and dokka*Doc are working fine on 1-4-0-rc. Tested on java 11 & JDK 16 eap (http://jdk.java.net/16/).

The Dokka JDK 11 compliance is what currently prevents me - and others, I presume - from releasing JDK 11 OSS projects through Sonatype OSS Nexus.

Is there some other means of generating JavaDoc for Kotlin? It may not need to be perfect, but it needs to exist in order to release OSS software.

Hi, we are working on this issue. The main problem is that in the JDK9+ the entire doclet model has changed and we have to reimplement the javadoc format from scratch, so it’s gonna take a while, but it’s planned for the next release

@kamildoleglo Hello friend. Sorry, I may not be understanding. Isn’t the latest dokka plugin 0.9.18?

Ref- https://plugins.gradle.org/plugin/org.jetbrains.dokka-android

No, you can see the full document of plugin version 1.4.32 from here: https://kotlin.github.io/dokka/1.4.32/

@kamilok1965 Thanks for the info. Could you add that mention in the README file? Currently it just seems like it should work and it’s a waste of time for everyone.

I did not manage to use Dokka when pushing a JDK 11 Kotlin project to OSS via Maven release. Any for this? Is there an estimate release date for Dokka 0.11 (being compliant with JDK 11)?

Any news on this? When can we expect a fix for it?

@drxeno02 the old Dokka versions are not supported, please switch to 1.4.32

Works for me too. Yay! Thank you so much! I’m kind of a Gradle noob, so my example is a little kludgy - any help would be appreciated!

I have to specify dokkaJar in my build command:

./gradlew clean assemble dokkaJar publish

Then in build.gradle.kts:

plugins {
    `java-library`
    `maven-publish`
    signing
    id("org.jetbrains.dokka") version "1.4.0-rc"
    kotlin("jvm") version "1.4.0"
}

java {
//    withJavadocJar()
    withSourcesJar()
}

// I made up a task named dokkaJar
tasks.register<Jar>("dokkaJar") {
    archiveClassifier.set("javadoc")
    dependsOn("dokkaJavadoc")
    from("$buildDir/dokka/javadoc/")
}

publishing {
    publications {
        create<MavenPublication>("mavenJava") {
            from(components["java"])
            afterEvaluate {
                artifactId = tasks.jar.get().archiveBaseName.get()
            }
            // Adds the dokka javadoc jar to this publication so it gets signed.
            artifact(tasks["dokkaJar"])

I deleted (because outputFormat is no longer valid):

tasks {
    val dokka by getting(DokkaTask::class) {
        outputFormat = "html"
        outputDirectory = "$buildDir/dokka"
    }
}

You most probably have different JDKs involved. In the IDE the gradle tasks usually run with the same JRE as the IDE does. Calling gradlew will either use Java-Home or whatever you have defined in the gradle.properties.

First of I’d like to thank everyone involved in dokka 💯 and I understand that the fix may take a while. I just have a question, might not be helpful but here I go.

Scenario v0.10.0

I get the following error if I run a command like ./gradlew dokka

The above is my task for generating documentation in all my modules

Execution failed for task ':dokka'.
> com/sun/tools/doclets/formats/html/HtmlDoclet

What’s strange is I can run the dokka task from the gradle toolbar in android studio for all the sub-modules (that have the dokka task) and this works without throwing an exceptions.

image

Honestly I don’t know why that is possible, I’d expect both methods to fail, 🤷‍♀️ and by no means am I gradle expert so perhaps someone could explain what differs between ./gradlew dokka and manually running the dokka task for each of the sub-modules

Configuration

So each of my sub-modules have a similar configuration as shown below

dokka {
    outputFormat = 'javadoc'
    outputDirectory = "$buildDir/docs/javadoc"

    configuration {
        moduleName = 'ui'
        reportUndocumented = true
        platform = "JVM"
        jdkVersion = 8

        perPackageOption {
            prefix = "kotlin"
            skipDeprecated = false
            reportUndocumented = true
            includeNonPublic = false
        }

        sourceLink {
            path = "src/main/kotlin"
            url = "https://github.com/anitrend/support-arch/tree/develop/support-ui/src/main/kotlin"
            lineSuffix = "#L"
        }

        externalDocumentationLink {
            url = new URL("https://developer.android.com/reference/kotlin/")
            packageListUrl = new URL("https://developer.android.com/reference/androidx/package-list")
        }
    }
}

the linked issue seemed to be fixed. Is there a new status for dokka?

@lennartj said:

The Dokka JDK 11 compliance is what currently prevents me - and others, I presume - from releasing JDK 11 OSS projects through Sonatype OSS Nexus.

I ran into the same thing when using Maven. I tried converting a project to Gradle 6.3 which happily creates a nearly empty myProject-javadoc.jar file without ever running dokka. I think the key lines in build.gradle.kts are:

java {
    withJavadocJar()
    withSourcesJar()
}

It puts nothing in myProject-javadoc.jar but a /META_INF/MANIFEST.MF file containing only a version string. Sonatype accepts this as a valid JavaDoc file.

If you have an all Kotlin project, you can even throw your dokka HTML into a javadoc-jar.

java {
//    withJavadocJar() // REMOVED THIS LINE
    withSourcesJar()
}

tasks {
    val dokka by getting(DokkaTask::class) {
        outputFormat = "html"
        outputDirectory = "$buildDir/dokka"
    }
}

tasks.register<Jar>("javadocJar") {
    archiveClassifier.set("javadoc")
    dependsOn("dokka")
    from("$buildDir/dokka")
}

I have maybe 8 hours of Gradle experience. I am not an expert. This is NOT a fix, or even a good workaround, but it might be better than no workaround. I’ll keep updating my build file here as I learn more: https://github.com/GlenKPeterson/Indented/blob/master/build.gradle.kts

Has HtmlDoclet moved to jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java in Java 11?http://hg.openjdk.java.net/jdk/jdk/file/82767203606e/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java

How are other people working around this? Do I need to install Java 8 in order to deploy to Sonatype? I’m willing to switch my build to Gradle, but it looks like it’s broken there too.