Reputation: 3758
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.
Upvotes: 6
Views: 1753
Reputation: 12680
Ant 1.9.4 now has failonwarning="true"
http://ant.apache.org/manual/Tasks/javadoc.html
Upvotes: 3
Reputation: 307
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"/>
Upvotes: 6
Reputation: 44215
I don't know about a JavaDoc parameter, I would recommend using a tool like checkstyle in your ant build for things like this. You can set it up to fail on Javadoc warnings.
Upvotes: 0