6

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"
        }
    }
}
Rangi Keen
  • 935
  • 9
  • 29

2 Answers2

10

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

options.addBooleanOption "-no-module-directories", true
Rangi Keen
  • 935
  • 9
  • 29
1

Alternatively, if you're not defining a custom task:

javadoc {
  doFirst {
    options.addBooleanOption('-no-module-directories', true)
  }
}

Adapted from a related post for specifying a module path.

hertzsprung
  • 9,445
  • 4
  • 42
  • 77