Alan Alan - 1 year ago 79
Java Question

determining whether javadoc encountered any errors or warnings

I would like to determine whether the javadoc command that we issue from a makefile encounters any errors or warnings. Currently, I can see that we're encountering errors due to import statements that are not on the classpath that we specify to javadoc (but should be). I ultimately want to fix our javadoc invocation and content and then lock it down so that any error or warning will be caught by the makefile and stop the build. However, as far as I can tell, the documentation does not mention any return code values from the javadoc command. Note that we're using Java 7 and running javadoc from a command in a GNU makefile, not from Ant or Maven. What do you recommend that I do?

UPDATE: My command looks like this:

<path1>/javadoc -overview <path2>/overview.html -sourcepath <path3> <file1> <file2> <dir1> <dir2> -d <output_dir>

There's nothing I can see in that call that would cause errors to be treated as warnings.

Here's a fragment from the output that shows the error/warning messages I'm seeing:

Constructing Javadoc information...
../../../<path>/<filename>.java:5: error: package javax.servlet.http does not exist
import javax.servlet.http.HttpSessionBindingEvent;

The word "error" appears in them, but at the end, the output says only "50 warnings". If I add another issue (such as the
tag suggested in one of the answers), I get 51 warnings.

Answer Source

Even though javadoc 1.7 reports errors, it returns with a zero return value, so the build doesn't catch it. However, javadoc 1.8 returns with a nonzero return value, which the build does catch.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download