ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine Levy Lambert <anto...@gmx.de>
Subject Re: Enhancement request: add option failonwarning to Javadoc task
Date Fri, 24 May 2013 10:58:45 GMT
Hello Tim,

thanks for suggesting this enhancement.

could you put this enhancement request in bugzilla, along with patches for the source, the
doc and if possible unit tests?

Regard,

Antoine
On May 23, 2013, at 1:07 PM, Boemker, Tim wrote:

> It would be useful if the javadoc task could fail a build if the javadoc program issued
any warnings.
>  
> One way to do this would be to add an option, failonwarning, and to modify org.apache.tools.ant.taskdefs.Javadoc
as follows:
>  
> --- /cygdrive/c/Users/tboemker/Desktop/jars/apache-ant-1.9.1-src/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
   2013-05-15 22:37:06.000000000 -0400
> +++ Javadoc.java        2013-05-23 12:55:38.875978100 -0400
> @@ -15,7 +15,7 @@
>   *  limitations under the License.
>   *
>   */
> -package org.apache.tools.ant.taskdefs;
> +package com.eLynx;
>  
> import java.io.File;
> import java.io.FileWriter;
> @@ -39,6 +39,9 @@
> import org.apache.tools.ant.Project;
> import org.apache.tools.ant.ProjectComponent;
> import org.apache.tools.ant.Task;
> +import org.apache.tools.ant.taskdefs.Execute;
> +import org.apache.tools.ant.taskdefs.LogOutputStream;
> +import org.apache.tools.ant.taskdefs.PumpStreamHandler;
> import org.apache.tools.ant.types.Commandline;
> import org.apache.tools.ant.types.DirSet;
> import org.apache.tools.ant.types.EnumeratedAttribute;
> @@ -423,6 +426,11 @@
>       * 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>();
> @@ -1540,6 +1548,17 @@
>      }
>  
>      /**
> +     * Should the build process fail if Javadoc warns (as indicated by
> +     * the word "warnings" in stdout)?
> +     *
> +     * <p>Default is false.</p>
> +     * @param b a <code>boolean</code> value
> +     */
> +    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
> @@ -1765,6 +1784,10 @@
>                  throw new BuildException("Javadoc returned " + ret,
>                                           getLocation());
>              }
> +            if (out.sawWarnings() && failOnWarning) {
> +                throw new BuildException("Javadoc issued warnings.",
> +                        getLocation());
> +            }
>          } catch (IOException e) {
>              throw new BuildException("Javadoc failed: " + e, e, getLocation());
>          } finally {
> @@ -2431,7 +2454,10 @@
>          // 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("warnings"))
> +                        sawWarnings = true;
>              if (messageLevel == Project.MSG_INFO
>                  && line.startsWith("Generating ")) {
>                  if (queuedLine != null) {
> @@ -2458,6 +2484,10 @@
>                  queuedLine = null;
>              }
>          }
> +
> +        public boolean sawWarnings() {
> +                return sawWarnings;
> +        }
>      }
>  
>      /**
>  
> 
>  
> Tim Boemker
> Sr. Software Engineer
> tboemker@elynx.com
> office: 513.612.5945
> fax: 513.612.5978
> www.elynx.com
>  
> enter the world of  
>  
>  
> Electronic Privacy Notice. This email may be covered by electronic communications privacy
laws and may be confidential or proprietary in nature. If you are not the intended recipient,
you are prohibited from retaining, using, copying, distributing or disclosing this email.
Instead, please reply to the sender that you have received this email in error, and then delete
it. Thank you.
>  
>  
>  


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message