Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

gradle

javadoc

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"
        }
    }
}
like image 375
Rangi Keen Avatar asked Dec 11 '18 21:12

Rangi Keen


2 Answers

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

options.addBooleanOption "-no-module-directories", true
like image 67
Rangi Keen Avatar answered Nov 17 '22 04:11

Rangi Keen


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.

like image 1
hertzsprung Avatar answered Nov 17 '22 04:11

hertzsprung