Javadoc: handle warnings as errors?

Can warnings be considered errors when using Javadoc? In particular, I call Javadoc from Ant and set failonerror="true" in my <javadoc> task, but I cannot run this. Although javadoc generates warnings, I still get a BUILD SUCCESSFUL with exit code 0 when Ant terminates.

I expect that I can add something to the additionalparam attribute of the <javadoc> task to cause a crash for Javadoc alerts.

+6
source share
3 answers

I know this is old, but it can still help someone who is looking for an answer like me. If it does not work, change

 <contains text="warnings"/> 

to the text that 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 ALL warnings, you should change this:

 <contains text="warnings"/> 
+6
source

Ant 1.9.4 now has failonwarning = "true"

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

+3
source

I don't know about the JavaDoc parameter, I would recommend using the checkstyle tool in your ant construct for things like this. You can configure it to reject Javadoc warnings.

0
source

Source: https://habr.com/ru/post/903144/


All Articles