Search code examples
antjavadoc

Capturing Ant <javadoc> task output


Is it possible to capture the warnings that Javadoc prints when run via the javadoc Ant task? I don't see an output attribute such as the one in the task. There seem to be warnings that Checkstyle just isn't catching and it'd be nice to snag that output in a file.

Seems strange this wouldn't be capturable, hopefully I'm missing something obvious.

~*~*~*~ EDIT (answer below) ~*~*~*~

It would appear the Ant <record> task is exactly what I was looking for. See the Ant docs.

<target name="generate.docs">
    <record name="javadoc.log" action="start"/>
    <javadoc ... />
    <record name="javadoc.log" action="stop"/>
<target/>

Solution

  • It looks like this is possible using the <exec> tag (reference here)... it would probably be a royal pain, but it might be possible to exec the javadoc executable and reconstruct the command arguments necessary to generate the javadoc. As a great big honking strike against, though, it appears that only uses your natural shell redirect, so building on both Win32 and Linux would require some special-case mojo.

    It may be worth it to write your own task to do the job; either the <redirect> tag as Roboprog has mentioned above, or extending the Javadoc task...