Add custom Javadoc option that does not take an argument

(Benjamin Jansen) #1

I am attempting to use the UmlGraph doclet with a Javadoc task. UmlGraphDoc has options that do not take an argument. Is there a way to pass these using gradle? I have tried various incantations of the add option methods of ‘CoreJavadocOptions’, but none have yielded the result I am looking for.

This is the ant doclet tag that I would need to translate. The ‘-inferrel’ and ‘-inferdep’ options don’t have args, for example.

<doclet name="org.umlgraph.doclet.UmlGraphDoc" path="${lib}/UMLGraph.jar">
            <param name="-inferrel"/>
            <param name="-inferdep"/>
            <param name="-hide" value="java.*"/>
            <param name="-collpackages" value="java.util.*"/>
            <param name="-qualify"/>
            <param name="-postfixpackage"/>
            <param name="-nodefontsize" value="9"/>
            <param name="-nodefontpackagesize" value="7"/>
            <param name="-link" value=""/>
            <param name="-link" value=""/>
task javadoc(type: Javadoc) {
  source subprojects.sourceSets*.main*.allJava
  classpath = files(subprojects.sourceSets*.main*.compileClasspath)
  options.docletpath = configurations.javadoclet.files.asType(List)
  options.doclet = 'org.umlgraph.doclet.UmlGraphDoc'
  options.classpath subprojects.sourceSets*.main*.classesDir
  options.memberLevel = 'PRIVATE'
  // These result in the option not being passed at all.
  options.addStringOption('inferrel', null)
  // This results in an empty string as an argument to the option, which is invalid.
  options.addStringOption('inferrel', '')

(Benjamin Jansen) #2

It appears that there is also no way to specify that an option should be listed multiple times. For example: “-hide foo -hide bar”. Invoking addStringOption() appears to end up putting the option in a map by name, so the last call’s value is the only one that is used.

(Jim Steel) #3

Has this issue changed in the last year?

(Michael Bannister) #4

@aogail, Did you ever figure this out? I’ve just hit the same problem.

(Michael Bannister) #5

Just figured out a way to make this work - found this example:

Here, the javadoc task includes options from a file:

options.optionFiles << file('javadoc.options')

where the javadoc.options file looks like this:

-doclet 'org.umlgraph.doclet.UmlGraphDoc' -attributes -types -inferrel