ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Exec.java
Date Tue, 25 Jan 2000 23:03:22 GMT
rubys       00/01/25 15:03:22

  Modified:    src/bin  antRun.bat
               src/main/org/apache/tools/ant Main.java Project.java
               src/main/org/apache/tools/ant/taskdefs Exec.java
  Log:
  Main: fixed a pb with the -D parameter
  Project: prints the os as well as jdk version
  taskdefs.Exec: Fixed issues with Win95
  Submitted by: Ludovic Claude <lc@websitewatchers.com>
  
  Revision  Changes    Path
  1.2       +2 -1      jakarta-ant/src/bin/antRun.bat
  
  Index: antRun.bat
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/bin/antRun.bat,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- antRun.bat	2000/01/13 10:41:39	1.1
  +++ antRun.bat	2000/01/25 23:03:21	1.2
  @@ -1,3 +1,4 @@
  +@echo off
   cd %1
   echo %2 %3 %4 %5 %6 %7 %8 %9
  -%2 %3 %4 %5 %6 %7 %8 %9 2>&1
  +%2 %3 %4 %5 %6 %7 %8 %9
  
  
  
  1.4       +14 -3     jakarta-ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Main.java	2000/01/24 00:15:07	1.3
  +++ Main.java	2000/01/25 23:03:21	1.4
  @@ -140,14 +140,25 @@
               } else if (arg.startsWith("-D")) {
   
                   /* Interestingly enough, we get to here when a user
  -                 * uses -Dname=value. However, the JDK goes ahead
  -                 * and parses this out to args {"-Dname", "value"}
  +                 * uses -Dname=value. However, in some cases, the JDK
  +                 * goes ahead * and parses this out to args 
  +                 *   {"-Dname", "value"}
                    * so instead of parsing on "=", we just make the "-D"
                    * characters go away and skip one argument forward.
  +                 *
  +                 * I don't know how to predict when the JDK is going
  +                 * to help or not, so we simply look for the equals sign.
                    */
   
                   String name = arg.substring(2, arg.length());
  -                String value = args[++i];
  +                String value = null;
  +                int posEq = name.indexOf("=");
  +                if (posEq > 0) {
  +                    value = name.substring(posEq+1);
  +                    name = name.substring(0, posEq);
  +                } else if (i < args.length)
  +                    value = args[++i];
  +
                   definedProps.put(name, value);
               } else if (arg.startsWith("-")) {
                   // we don't have any more args to recognize!
  
  
  
  1.4       +2 -0      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Project.java	2000/01/24 00:15:08	1.3
  +++ Project.java	2000/01/25 23:03:21	1.4
  @@ -270,6 +270,8 @@
           }
   
           log("Detected Java Version: " + javaVersion);
  +
  +        log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
       }
   
       public void addTaskDefinition(String taskName, Class taskClass) {
  
  
  
  1.3       +24 -19    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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Exec.java	2000/01/23 11:39:13	1.2
  +++ Exec.java	2000/01/25 23:03:22	1.3
  @@ -97,29 +97,17 @@
   
               // exec command on system runtime
               Process proc = Runtime.getRuntime().exec(command);
  -            
  -            // get process response
  -            BufferedReader din = new BufferedReader(new InputStreamReader(proc.getInputStream()));
   
  -            // if "out" attribute is present, redirect to it
  -            PrintWriter fos = null;
  -            if (out != null)  {
  -                fos = new PrintWriter(new FileWriter(out));
  +            PrintWriter fos=null;
  +            if( out!=null )  {
  +                fos=new PrintWriter( new FileWriter( out ) );
                   project.log("Output redirected to " + out, Project.MSG_VERBOSE);
  -            }
  -
  -
  -            // pipe the process output
  -            String line;
  -            while((line = din.readLine()) != null) {
  -                if (fos == null) {
  -                    project.log(line, "exec", Project.MSG_INFO);
  -                } else {
  -                    fos.println(line);
  -                }
               }
  +            pipeOutput(proc.getInputStream(), "exec", fos);
  +            pipeOutput(proc.getErrorStream(), "error", fos);
  +            if (null != fos)
  +        	fos.close();
   
  -            // wait until the process is finished
               proc.waitFor();
               
               // close the output file if required 
  @@ -150,5 +138,22 @@
   
       public void setOutput(String out) {
           this.out = out;
  +    }
  +
  +    private void pipeOutput(InputStream is, String name, PrintWriter fos) 
  +        throws IOException 
  +    {
  +project.log("pipeOutput", name, Project.MSG_INFO);
  +        InputStreamReader isr=new InputStreamReader(is);
  +        BufferedReader din = new BufferedReader(isr);
  +
  +        // pipe output to STDOUT
  +        String line;
  +        while((line = din.readLine()) != null) {
  +        if( fos==null)
  +            project.log(line, name, Project.MSG_INFO);
  +        else
  +            fos.println(line);
  +        }
       }
   }
  
  
  

Mime
View raw message