You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ru...@locus.apache.org on 2000/07/05 21:38:50 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Exec.java Javadoc.java

rubys       00/07/05 12:38:40

  Modified:    src/main/org/apache/tools/ant/taskdefs Exec.java
                        Javadoc.java
  Log:
  Override the logging of Javadoc output in order to filter out
  Generating messages.  Generating messages are set to a priority
  of VERBOSE unless they appear after what could be an
  informational message.
  
  Revision  Changes    Path
  1.12      +20 -13    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java
  
  Index: Exec.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Exec.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Exec.java	2000/07/03 12:26:26	1.11
  +++ Exec.java	2000/07/05 19:38:31	1.12
  @@ -69,6 +69,7 @@
       private String out;
       private File dir;
       private String command;
  +    protected PrintWriter fos = null;
   
       private static final int BUFFER_SIZE = 512;
   
  @@ -110,7 +111,6 @@
               // exec command on system runtime
               Process proc = Runtime.getRuntime().exec(command);
   
  -            PrintWriter fos=null;
               if( out!=null )  {
                   fos=new PrintWriter( new FileWriter( out ) );
                   project.log("Output redirected to " + out, Project.MSG_VERBOSE);
  @@ -118,9 +118,9 @@
   
               // copy input and error to the output stream
               StreamPumper inputPumper =
  -                new StreamPumper(proc.getInputStream(), Project.MSG_INFO, project, fos);
  +                new StreamPumper(proc.getInputStream(), Project.MSG_INFO, this);
               StreamPumper errorPumper =
  -                new StreamPumper(proc.getErrorStream(), Project.MSG_WARN, project, fos);
  +                new StreamPumper(proc.getErrorStream(), Project.MSG_WARN, this);
   
               // starts pumping away the generated output/error
               inputPumper.start();
  @@ -133,7 +133,7 @@
               proc.destroy();
   
               // close the output file if required
  -            if (fos != null) fos.close();
  +            logFlush();
   
               // check its exit value
               err = proc.exitValue();
  @@ -163,6 +163,18 @@
           this.out = out;
       }
   
  +    protected void outputLog(String line, int messageLevel) {
  +        if (fos == null) {
  +            project.log(line, messageLevel); 
  +        } else {
  +            fos.println(line);
  +        }
  +    };
  +
  +    protected void logFlush() {
  +        if (fos != null) fos.close();
  +    }
  +
       // Inner class for continually pumping the input stream during
       // Process's runtime.
       class StreamPumper extends Thread {
  @@ -170,14 +182,12 @@
           private int messageLevel;
           private boolean endOfStream = false;
           private int SLEEP_TIME = 5;
  -        private Project project;
  -        private PrintWriter fos;
  +        private Exec parent;
   
  -        public StreamPumper(InputStream is, int messageLevel, Project project, PrintWriter fos) {
  +        public StreamPumper(InputStream is, int messageLevel, Exec parent) {
               this.din = new BufferedReader(new InputStreamReader(is));
               this.messageLevel = messageLevel;
  -            this.project = project;
  -            this.fos = fos;
  +            this.parent = parent;
           }
   
           public void pumpStream()
  @@ -188,10 +198,7 @@
                   String line = din.readLine();
   
                   if (line != null) {
  -                    if (fos == null)
  -                        project.log(line, messageLevel);
  -                    else
  -                        fos.println(line);
  +                    outputLog(line, messageLevel);
                   } else {
                       endOfStream = true;
                   }
  
  
  
  1.12      +32 -0     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  
  Index: Javadoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javadoc.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- Javadoc.java	2000/07/04 09:25:56	1.11
  +++ Javadoc.java	2000/07/05 19:38:31	1.12
  @@ -727,6 +727,38 @@
           return name;
       }
   
  +    //
  +    // Override the logging of output in order to filter out Generating
  +    // messages.  Generating messages are set to a priority of VERBOSE
  +    // unless they appear after what could be an informational message.
  +    //
  +    private String queuedLine = null;
  +    protected void outputLog(String line, int messageLevel) {
  +        if (messageLevel==project.MSG_INFO && line.startsWith("Generating ")) {
  +            if (queuedLine != null) {
  +                super.outputLog(queuedLine, project.MSG_VERBOSE);
  +            }
  +            queuedLine = line;
  +        } else {
  +            if (queuedLine != null) {
  +                if (line.startsWith("Building "))
  +                    super.outputLog(queuedLine, project.MSG_VERBOSE);
  +                else
  +                    super.outputLog(queuedLine, project.MSG_INFO);
  +                queuedLine = null;
  +            }
  +            super.outputLog(line, messageLevel);
  +        }
  +    }
  +
  +    protected void logFlush() {
  +        if (queuedLine != null) {
  +            super.outputLog(queuedLine, project.MSG_VERBOSE);
  +            queuedLine = null;
  +        }
  +        super.logFlush();
  +    }
  +
       /**
        * This is a java comment and string stripper reader that filters
        * these lexical tokens out for purposes of simple Java parsing.