Search code examples
gradlejavadoc

Gradle javadoc Search redirects to “/undefined/..” URL


I'm generating the javadoc using Java 11 and gradle for a project that does not use modules using the configuration below.

The documentation is generated correctly, but navigating to a search result yields a file not found instead of the expected page. There is an extra "undefined/" in the URL before the package and class name (e.g. ".../doc/undefined/package/Class.html").

There is a similar question for javadoc with Maven, but I cannot see how to add the --no-module-directories option in gradle.

task allJavadoc (type: Javadoc, description: 'Generate javadoc from all projects', group: 'Documentation') {
    destinationDir = file("$projectDir/doc")
    title = "Title"
    maxMemory = "2048m"
    failOnError true
    options.author false
    options.version true
    options.use true
    options.links "https://docs.oracle.com/en/java/javase/11/docs/api/"
    options.breakIterator true

    subprojects.each { proj ->
        proj.tasks.withType(Javadoc).each { javadocTask ->
            classpath += javadocTask.classpath
            excludes += javadocTask.excludes
            includes += "**/*.java"
        }
    }
}

Solution

  • You need to add a boolean option with the leading hyphen removed:

    options.addBooleanOption "-no-module-directories", true