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.
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"/>
Ant 1.9.4 now has failonwarning="true"
http://ant.apache.org/manual/Tasks/javadoc.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With