Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javadoc: Treat warnings as errors?

Tags:

javadoc

ant

Is it possible to treat warnings as errors when using Javadoc? In particular, I am calling Javadoc from Ant and have failonerror="true" set on my <javadoc> task, but I cannot seem to trigger this. Even though javadoc is generating warnings, I am still getting BUILD SUCCESSFUL with an exit code of 0 when Ant completes.

I would expect to be able to add something to the additionalparam attribute of the <javadoc> task to force a failure for Javadoc warnings.

like image 779
bolinfest Avatar asked Dec 05 '11 22:12

bolinfest


2 Answers

I know this is old but it might still be helpful for someone looking for the answer like I was. If it doesn't work change the

<contains text="warnings"/>

to the text you see with your output.

<target name="javadoc">
<delete dir="${jDocDirectory}"/> 
<mkdir dir="${jDocDirectory}"/> 
<record name="javadocLog" action="start"/>
<javadoc (settings, blah blah) />
<record name="javadocLog" action="stop"/>
        <condition property="javadoc.warnings">
            <isfileselected file="javadocLog">
                <contains text="warnings"/>
             </isfileselected>
        </condition>
        <fail if="javadoc.warnings">Javadoc warnings!</fail>
</target>

edit: If you have one warning this will not work, to fix for ALL warnings you must change this:

<contains text="warnings"/>
like image 127
Knoxie Avatar answered Oct 24 '22 00:10

Knoxie


Ant 1.9.4 now has failonwarning="true"

http://ant.apache.org/manual/Tasks/javadoc.html

like image 43
Hakanai Avatar answered Oct 23 '22 22:10

Hakanai