ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stef...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Exec.java
Date Thu, 27 Jan 2000 03:57:33 GMT
stefano     00/01/26 19:57:33

  Modified:    src/main/org/apache/tools/ant/taskdefs Exec.java
  Log:
  transformed tabs into spaces...
  
  BTW, Sam, my tests show the pumping threads
  slow down the process to half of its original speed,
  we should use a better method for this...
  
  Revision  Changes    Path
  1.5       +38 -40    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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Exec.java	2000/01/26 03:46:06	1.4
  +++ Exec.java	2000/01/27 03:57:32	1.5
  @@ -58,9 +58,10 @@
   import java.io.*;
   
   /**
  + * Executes a given command if the os platform is appropriate.
    *
  - *
    * @author duncan@x180.com
  + * @author rubys@us.ibm.com
    */
   
   public class Exec extends Task {
  @@ -80,19 +81,19 @@
               project.log("Not found in " + os, Project.MSG_VERBOSE);
               return;
           }
  -        
  +
           String ant = project.getProperty("ant.home");
           if (ant == null) throw new BuildException("Property 'ant.home' not found");
   
           String antRun = project.resolveFile(ant + "/bin/antRun").toString();
           if (myos.toLowerCase().indexOf("windows") >= 0) antRun = antRun + ".bat";
           command = antRun + " " + project.resolveFile(dir) + " " + command;
  -        
  +
           run(command);
       }
   
       protected void run(String command) throws BuildException {
  -        
  +
           try {
               // show the command
               project.log(command, "exec", Project.MSG_VERBOSE);
  @@ -107,11 +108,12 @@
               }
   
               // copy input and error to the output stream
  -            StreamPumper inputPumper = 
  +            StreamPumper inputPumper =
                   new StreamPumper(proc.getInputStream(), "exec", project, fos);
  -            StreamPumper errorPumper = 
  +            StreamPumper errorPumper =
                   new StreamPumper(proc.getErrorStream(), "error", project, fos);
   
  +            // starts pumping away the generated output/error
               inputPumper.start();
               errorPumper.start();
   
  @@ -121,7 +123,7 @@
               errorPumper.join();
               proc.destroy();
   
  -            // close the output file if required 
  +            // close the output file if required
               if (fos != null) fos.close();
   
               // check its exit value
  @@ -131,8 +133,7 @@
               }
           } catch (IOException ioe) {
               throw new BuildException("Error exec: " + command );
  -        } catch (InterruptedException ex) {
  -        }
  +        } catch (InterruptedException ex) {}
       }
   
       public void setDir(String d) {
  @@ -154,51 +155,48 @@
       // Inner class for continually pumping the input stream during
       // Process's runtime.
       class StreamPumper extends Thread {
  -	private BufferedReader din;
  +        private BufferedReader din;
           private String name;
  -	private boolean endOfStream = false;
  -	private int SLEEP_TIME = 5;
  +        private boolean endOfStream = false;
  +        private int SLEEP_TIME = 5;
           private Project project;
  -	private PrintWriter fos;
  +        private PrintWriter fos;
   
  -	public StreamPumper(InputStream is, String name, Project project, PrintWriter fos) {
  +        public StreamPumper(InputStream is, String name, Project project, PrintWriter fos)
{
               this.din     = new BufferedReader(new InputStreamReader(is));
               this.name    = name;
               this.project = project;
  -	    this.fos     = fos;
  -	}
  +            this.fos     = fos;
  +        }
   
  -	public void pumpStream()
  -	    throws IOException
  -	{
  -	    byte[] buf = new byte[BUFFER_SIZE];
  -	    if (!endOfStream) {
  +        public void pumpStream()
  +            throws IOException
  +        {
  +            byte[] buf = new byte[BUFFER_SIZE];
  +            if (!endOfStream) {
                   String line = din.readLine();
   
  -		if (line != null) {
  -                    if (fos==null)
  +                if (line != null) {
  +                    if (fos == null)
                           project.log(line, name, Project.MSG_INFO);
                       else
                           fos.println(line);
  -		} else {
  -		    endOfStream=true;
  -		}
  -	    }
  -	}
  +                } else {
  +                    endOfStream = true;
  +                }
  +            }
  +        }
   
  -	public void run() {
  +        public void run() {
               try {
  -	        try {
  -		    while (!endOfStream) {
  -		        pumpStream();
  -		        sleep(SLEEP_TIME);
  -		    }
  -	        } catch (InterruptedException ie) {
  -                }
  +                try {
  +                    while (!endOfStream) {
  +                        pumpStream();
  +                        sleep(SLEEP_TIME);
  +                    }
  +                } catch (InterruptedException ie) {}
                   din.close();
  -	    } catch (IOException ioe) {
  -	    }
  -	}
  +            } catch (IOException ioe) {}
  +        }
       }
  -
   }
  
  
  

Mime
View raw message