6

I recently upgraded my development environment from Java 7 to Java 8, which now finds a large number of previously-undetected javadoc issues.

By default, Ant (invoked via Eclipse Mars) limits its warnings (and I assume errors) to 100:

Ant warnings limited to 100

Is there any parameter to force Ant to display all javadoc warnings instead of limiting to 100?

I attempted to use the -Xmaxwarns 1000 parameter via the compilerarg element, but it appears that the current Ant version in Eclipse Mars (Ant 1.9.4) javadoc task does not support the compilerarg element (it is only supported in the javac task):

<!-- Generate the API documentation. -->
<target name="javadoc" depends="clean" description="Generate the API documentation.">

    <!-- Create the build directory structure used by javadoc. -->
    <mkdir dir="${build.folder}" />
    <mkdir dir="${docs.folder}" />

    <!-- Run javadoc. -->

    <javadoc destdir="${docs.folder}/api" author="true" version="true" use="true" windowtitle="${documentation.title}">

        <compilerarg value="-Xmaxerrs 1000 -Xmaxwarns 1000" />

        <classpath>

        ...

ant: javadoc doesn't support the nested "compilerarg" element.

Java 8 javadoc does support these parameters (support was added in Java 7 b100):

C:\>javadoc -X
  -Xmaxerrs <number>               Set the maximum number of errors to print
  -Xmaxwarns <number>              Set the maximum number of warnings to print

Provided by standard doclet:
  -Xdocrootparent <url>            Replaces all appearances of @docRoot followed

                                   by /.. in doc comments with <url>
  -Xdoclint                        Enable recommended checks for problems in javadoc comments
  -Xdoclint:(all|none|[-]<group>)
        Enable or disable specific checks for problems in javadoc comments,
        where <group> is one of accessibility, html, missing, reference, or syntax.

These options are non-standard and subject to change without notice.

Conclusion: It appears that the Ant javadoc task is the limiting factor here, and if it supported the compilerarg flag, it would be possible to adjust the limit on errors and warnings.

Parker
  • 7,244
  • 12
  • 70
  • 92
  • 2
    Is it _ant_ or _javadoc_ limiting the warning count? Could you please run javadoc from the command line? – Seelenvirtuose Sep 18 '15 at 05:48
  • 1
    @Seelenvirtuose Ultimately, javadoc was limiting the warning messages to 100. I was looking for a way to control that when launching javadoc via Ant. – Parker Sep 18 '15 at 15:50

1 Answers1

7

As you noted, -Xmaxwarns affects how many warnings the javadoc program outputs.

-Xmaxwarns can be passed to the javadoc program with nested <arg> elements:

<javadoc ...>
    <arg value="-Xmaxwarns"/>
    <arg value="200"/>
</javadoc>

In my own test case, I was able to increase the reported warnings above 100:

[javadoc] Generating Javadoc
...
[javadoc] 112 warnings
Chad Nouis
  • 6,861
  • 1
  • 27
  • 28
  • 1
    This works perfectly. I wasn't aware that multiple args could be catenated that way in ant. – Parker Sep 18 '15 at 15:47