diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 7a4ae0b39..7e9346fad 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -360,6 +360,7 @@ Thomas Christen Thomas Christensen Thomas Haas Thomas Quas +Tim Boemker Tim Drury Tim Fennell Tim Stephenson diff --git a/WHATSNEW b/WHATSNEW index 6720e8802..c41ace5dc 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -85,6 +85,9 @@ Other changes: process and setting a property from the return code. Bugzilla Report 48478 + * now has an option to fail if javadoc issues warnings. + Bugzilla Report 55015 + Changes from Ant 1.9.2 TO Ant 1.9.3 =================================== diff --git a/contributors.xml b/contributors.xml index 55ddebda2..ea1dece85 100644 --- a/contributors.xml +++ b/contributors.xml @@ -1451,6 +1451,10 @@ Thomas Quas + + Tim + Boemker + Tim Drury diff --git a/manual/Tasks/javadoc.html b/manual/Tasks/javadoc.html index 31f3f3e38..5ee8528d1 100644 --- a/manual/Tasks/javadoc.html +++ b/manual/Tasks/javadoc.html @@ -415,6 +415,14 @@ to <javadoc> using classpath, classpathref attributes or all No + + failonwarning + Stop the buildprocess if a warning is emitted - + i.e. if javadoc's output contains the word "warning". since + Ant 1.9.4 + all + No + excludepackagenames comma separated list of packages you don't want diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 572720448..f0e7bb166 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -434,6 +434,11 @@ public class Javadoc extends Task { * Javadoc error. */ private boolean failOnError = false; + /** + * Flag which indicates if the task should fail if there is a + * Javadoc warning. + */ + private boolean failOnWarning = false; private Path sourcePath = null; private File destDir = null; private Vector sourceFiles = new Vector(); @@ -1553,6 +1558,18 @@ public class Javadoc extends Task { failOnError = b; } + /** + * Should the build process fail if Javadoc warns (as indicated by + * the word "warning" on stdout)? + * + *

Default is false.

+ * @param b a boolean value + * @since Ant 1.9.4 + */ + public void setFailonwarning(boolean b) { + failOnWarning = b; + } + /** * Enables the -source switch, will be ignored if Javadoc is not * the 1.4 version. @@ -1787,6 +1804,10 @@ public class Javadoc extends Task { throw new BuildException("Javadoc returned " + ret, getLocation()); } + if (out.sawWarnings() && failOnWarning) { + throw new BuildException("Javadoc issued warnings.", + getLocation()); + } postProcessGeneratedJavadocs(); } catch (IOException e) { throw new BuildException("Javadoc failed: " + e, e, getLocation()); @@ -2548,7 +2569,11 @@ public class Javadoc extends Task { // unless they appear after what could be an informational message. // private String queuedLine = null; + private boolean sawWarnings = false; protected void processLine(String line, int messageLevel) { + if (line.contains("warning")) { + sawWarnings = true; + } if (messageLevel == Project.MSG_INFO && line.startsWith("Generating ")) { if (queuedLine != null) { @@ -2575,6 +2600,10 @@ public class Javadoc extends Task { queuedLine = null; } } + + public boolean sawWarnings() { + return sawWarnings; + } } /**