ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Execute.java
Date Tue, 23 Jul 2002 19:51:11 GMT
sbailliez    2002/07/23 12:51:11

  Modified:    src/main/org/apache/tools/ant/taskdefs Tag: ANT_15_BRANCH
                        Execute.java
  Log:
  Backmerge from 1.46 ... do it the other way around next time.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.43.2.4  +41 -39    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java
  
  Index: Execute.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Execute.java,v
  retrieving revision 1.43.2.3
  retrieving revision 1.43.2.4
  diff -u -r1.43.2.3 -r1.43.2.4
  --- Execute.java	28 May 2002 07:06:48 -0000	1.43.2.3
  +++ Execute.java	23 Jul 2002 19:51:11 -0000	1.43.2.4
  @@ -74,7 +74,7 @@
    * Runs an external program.
    *
    * @author thomas.haas@softwired-inc.com
  - * @author <a href="mailto:jtulley@novell.com">Jeff Tulley</a> 
  + * @author <a href="mailto:jtulley@novell.com">Jeff Tulley</a>
    *
    * @since Ant 1.2
    *
  @@ -139,7 +139,7 @@
                   shellLauncher = new WinNTCommandLauncher(baseLauncher);
               } else {
                   // Windows 98/95 - need to use an auxiliary script
  -                shellLauncher 
  +                shellLauncher
                       = new ScriptCommandLauncher("bin/antRun.bat", baseLauncher);
               }
           } else if (Os.isFamily("netware")) {
  @@ -153,11 +153,11 @@
                   baseLauncher = new CommandLauncher();
               }
   
  -            shellLauncher 
  +            shellLauncher
                   = new PerlScriptCommandLauncher("bin/antRun.pl", baseLauncher);
           } else {
               // Generic
  -            shellLauncher = new ScriptCommandLauncher("bin/antRun", 
  +            shellLauncher = new ScriptCommandLauncher("bin/antRun",
                   new CommandLauncher());
           }
       }
  @@ -182,9 +182,9 @@
                   // Just try to use what we got
               }
   
  -            BufferedReader in = 
  +            BufferedReader in =
                   new BufferedReader(new StringReader(toString(out)));
  -                
  +
               String var = null;
               String line, lineSep = System.getProperty("line.separator");
               while ((line = in.readLine()) != null) {
  @@ -295,7 +295,7 @@
        * @param watchdog a watchdog for the subprocess or <code>null</code> to
        *        to disable a timeout for the subprocess.
        */
  -    public Execute(ExecuteStreamHandler streamHandler, 
  +    public Execute(ExecuteStreamHandler streamHandler,
                      ExecuteWatchdog watchdog) {
           this.streamHandler = streamHandler;
           this.watchdog = watchdog;
  @@ -387,7 +387,7 @@
        * executable with a script, etc
        *
        * @param useVMLauncher true if exec should launch through thge VM,
  -     *                   false if the shell should be used to launch the 
  +     *                   false if the shell should be used to launch the
        *                   command.
        */
       public void setVMLauncher(boolean useVMLauncher) {
  @@ -405,10 +405,10 @@
        *
        * @since Ant 1.5
        */
  -    public static Process launch(Project project, String[] command, 
  +    public static Process launch(Project project, String[] command,
                                    String[] env, File dir, boolean useVM)
           throws IOException {
  -        CommandLauncher launcher 
  +        CommandLauncher launcher
               = vmLauncher != null ? vmLauncher : shellLauncher;
           if (!useVM) {
               launcher = shellLauncher;
  @@ -425,8 +425,8 @@
        *            of the subprocess failed
        */
       public int execute() throws IOException {
  -        final Process process = launch(project, getCommandline(), 
  -                                       getEnvironment(), workingDirectory, 
  +        final Process process = launch(project, getCommandline(),
  +                                       getEnvironment(), workingDirectory,
                                          useVMLauncher);
   
           try {
  @@ -466,7 +466,9 @@
           try {
               process.waitFor();
               setExitValue(process.exitValue());
  -        } catch (InterruptedException e) {}
  +        } catch (InterruptedException e) {
  +            process.destroy();
  +        }
       }
   
       protected void setExitValue(int value) {
  @@ -524,10 +526,10 @@
        *
        * @throws BuildException if the command does not return 0.
        */
  -    public static void runCommand(Task task, String[] cmdline) 
  +    public static void runCommand(Task task, String[] cmdline)
           throws BuildException {
           try {
  -            task.log(Commandline.describeCommand(cmdline), 
  +            task.log(Commandline.describeCommand(cmdline),
                        Project.MSG_VERBOSE);
               Execute exe = new Execute(new LogStreamHandler(task,
                                                              Project.MSG_INFO,
  @@ -536,11 +538,11 @@
               exe.setCommandline(cmdline);
               int retval = exe.execute();
               if (retval != 0) {
  -                throw new BuildException(cmdline[0] 
  +                throw new BuildException(cmdline[0]
                       + " failed with return code " + retval, task.getLocation());
               }
           } catch (java.io.IOException exc) {
  -            throw new BuildException("Could not launch " + cmdline[0] + ": " 
  +            throw new BuildException("Could not launch " + cmdline[0] + ": "
                   + exc, task.getLocation());
           }
       }
  @@ -559,11 +561,11 @@
            * @param env           The environment for the new process.  If null,
            *                      the environment of the current proccess is used.
            */
  -        public Process exec(Project project, String[] cmd, String[] env) 
  +        public Process exec(Project project, String[] cmd, String[] env)
                throws IOException {
               if (project != null) {
                   project.log("Execute:CommandLauncher: " +
  -                            Commandline.describeCommand(cmd), 
  +                            Commandline.describeCommand(cmd),
                               Project.MSG_DEBUG);
               }
               return Runtime.getRuntime().exec(cmd, env);
  @@ -580,12 +582,12 @@
            * @param workingDir    The directory to start the command in.  If null,
            *                      the current directory is used
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               if (workingDir == null) {
                   return exec(project, cmd, env);
               }
  -            throw new IOException("Cannot execute a process in different " 
  +            throw new IOException("Cannot execute a process in different "
                   + "directory under this JVM");
           }
       }
  @@ -600,9 +602,9 @@
            * Launches the given command in a new process.  Needs to quote
            * arguments
            */
  -        public Process exec(Project project, String[] cmd, String[] env) 
  +        public Process exec(Project project, String[] cmd, String[] env)
                throws IOException {
  -            // Need to quote arguments with spaces, and to escape 
  +            // Need to quote arguments with spaces, and to escape
               // quote characters
               String[] newcmd = new String[cmd.length];
               for (int i = 0; i < cmd.length; i++) {
  @@ -623,9 +625,9 @@
        */
       private static class Java13CommandLauncher extends CommandLauncher {
           public Java13CommandLauncher() throws NoSuchMethodException {
  -            // Locate method Runtime.exec(String[] cmdarray, 
  +            // Locate method Runtime.exec(String[] cmdarray,
               //                            String[] envp, File dir)
  -            _execWithCWD = Runtime.class.getMethod("exec", 
  +            _execWithCWD = Runtime.class.getMethod("exec",
                   new Class[] {String[].class, String[].class, File.class});
           }
   
  @@ -633,7 +635,7 @@
            * Launches the given command in a new process, in the given working
            * directory
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               try {
                   if (project != null) {
  @@ -642,7 +644,7 @@
                                   Project.MSG_DEBUG);
                   }
                   Object[] arguments = { cmd, env, workingDir };
  -                return (Process) _execWithCWD.invoke(Runtime.getRuntime(), 
  +                return (Process) _execWithCWD.invoke(Runtime.getRuntime(),
                                                        arguments);
               } catch (InvocationTargetException exc) {
                   Throwable realexc = exc.getTargetException();
  @@ -651,7 +653,7 @@
                   } else if (realexc instanceof IOException) {
                       throw (IOException) realexc;
                   } else {
  -                    throw new BuildException("Unable to execute command", 
  +                    throw new BuildException("Unable to execute command",
                                                realexc);
                   }
               } catch (Exception exc) {
  @@ -677,7 +679,7 @@
            * Launches the given command in a new process.  Delegates this
            * method to the proxied launcher
            */
  -        public Process exec(Project project, String[] cmd, String[] env) 
  +        public Process exec(Project project, String[] cmd, String[] env)
               throws IOException {
               return _launcher.exec(project, cmd, env);
           }
  @@ -699,7 +701,7 @@
            * Launches the given command in a new process, in the given working
            * directory.
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               File commandDir = workingDir;
               if (workingDir == null) {
  @@ -739,7 +741,7 @@
            * Launches the given command in a new process, in the given working
            * directory
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               if (workingDir == null) {
                   return exec(project, cmd, env);
  @@ -768,20 +770,20 @@
            * Launches the given command in a new process, in the given working
            * directory
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               if (project == null) {
                   if (workingDir == null) {
                       return exec(project, cmd, env);
                   }
  -                throw new IOException("Cannot locate antRun script: " 
  +                throw new IOException("Cannot locate antRun script: "
                       + "No project provided");
               }
   
               // Locate the auxiliary script
               String antHome = project.getProperty("ant.home");
               if (antHome == null) {
  -                throw new IOException("Cannot locate antRun script: " 
  +                throw new IOException("Cannot locate antRun script: "
                       + "Property 'ant.home' not found");
               }
               String antRun = project.resolveFile(antHome + File.separator + _script).toString();
  @@ -807,7 +809,7 @@
        * A command launcher that uses an auxiliary perl script to launch commands
        * in directories other than the current working directory.
        */
  -    private static class PerlScriptCommandLauncher 
  +    private static class PerlScriptCommandLauncher
           extends CommandLauncherProxy {
           PerlScriptCommandLauncher(String script, CommandLauncher launcher) {
               super(launcher);
  @@ -818,20 +820,20 @@
            * Launches the given command in a new process, in the given working
            * directory
            */
  -        public Process exec(Project project, String[] cmd, String[] env, 
  +        public Process exec(Project project, String[] cmd, String[] env,
                               File workingDir) throws IOException {
               if (project == null) {
                   if (workingDir == null) {
                       return exec(project, cmd, env);
                   }
  -                throw new IOException("Cannot locate antRun script: " 
  +                throw new IOException("Cannot locate antRun script: "
                       + "No project provided");
               }
   
               // Locate the auxiliary script
               String antHome = project.getProperty("ant.home");
               if (antHome == null) {
  -                throw new IOException("Cannot locate antRun script: " 
  +                throw new IOException("Cannot locate antRun script: "
                       + "Property 'ant.home' not found");
               }
               String antRun = project.resolveFile(antHome + File.separator + _script).toString();
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message