Author: bodewig
Date: Mon Jan  6 17:35:34 2014
New Revision: 1555938

URL: http://svn.apache.org/r1555938
Log:
failOnWarning attribute for javadoc.  Patch by Tim Boemker.  PR 55015

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/contributors.xml
    ant/core/trunk/manual/Tasks/javadoc.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=1555938&r1=1555937&r2=1555938&view=diff
==============================================================================
--- ant/core/trunk/CONTRIBUTORS (original)
+++ ant/core/trunk/CONTRIBUTORS Mon Jan  6 17:35:34 2014
@@ -360,6 +360,7 @@ Thomas Christen
 Thomas Christensen
 Thomas Haas
 Thomas Quas
+Tim Boemker
 Tim Drury
 Tim Fennell
 Tim Stephenson

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1555938&r1=1555937&r2=1555938&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Jan  6 17:35:34 2014
@@ -85,6 +85,9 @@ Other changes:
    process and setting a property from the return code.
    Bugzilla Report 48478
 
+ * <javadoc> now has an option to fail if javadoc issues warnings.
+   Bugzilla Report 55015
+
 Changes from Ant 1.9.2 TO Ant 1.9.3
 ===================================
 

Modified: ant/core/trunk/contributors.xml
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=1555938&r1=1555937&r2=1555938&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Mon Jan  6 17:35:34 2014
@@ -1453,6 +1453,10 @@
   </name>
   <name>
     <first>Tim</first>
+    <last>Boemker</last>
+  </name>
+  <name>
+    <first>Tim</first>
     <last>Drury</last>
   </name>
   <name>

Modified: ant/core/trunk/manual/Tasks/javadoc.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/manual/Tasks/javadoc.html?rev=1555938&r1=1555937&r2=1555938&view=diff
==============================================================================
--- ant/core/trunk/manual/Tasks/javadoc.html (original)
+++ ant/core/trunk/manual/Tasks/javadoc.html Mon Jan  6 17:35:34 2014
@@ -416,6 +416,14 @@ to &lt;javadoc&gt; using <tt>classpath</
     <td align="center" valign="top">No</td>
   </tr>
   <tr>
+    <td valign="top">failonwarning</td>
+    <td valign="top">Stop the buildprocess if a warning is emitted -
+    i.e. if javadoc's output contains the word "warning".  <em>since
+    Ant 1.9.4</em></td>
+    <td align="center" valign="top">all</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
     <td valign="top">excludepackagenames</td>
     <td valign="top">comma separated list of packages you don't want
       docs for -- see also the nested <code>excludepackage</code> element.</td>

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java?rev=1555938&r1=1555937&r2=1555938&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java 
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Javadoc.java Mon Jan  
6 17:35:34 2014
@@ -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<SourceFile> sourceFiles = new Vector<SourceFile>();
@@ -1554,6 +1559,18 @@ public class Javadoc extends Task {
     }
 
     /**
+     * Should the build process fail if Javadoc warns (as indicated by
+     * the word "warning" on stdout)?
+     *
+     * <p>Default is false.</p>
+     * @param b a <code>boolean</code> 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.
      * @param source a <code>String</code> value
@@ -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;
+        }
     }
 
     /**


Reply via email to