ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs ExecuteJava.java Java.java
Date Thu, 11 Apr 2002 14:58:01 GMT
bodewig     02/04/11 07:58:00

  Modified:    src/main/org/apache/tools/ant/taskdefs ExecuteJava.java
                        Java.java
  Log:
  <java> may alter value of dir during execute.  Cosmetics.
  
  Revision  Changes    Path
  1.24      +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- ExecuteJava.java	8 Apr 2002 15:40:33 -0000	1.23
  +++ ExecuteJava.java	11 Apr 2002 14:58:00 -0000	1.24
  @@ -73,6 +73,7 @@
    *
    * @author thomas.haas@softwired-inc.com
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
  + * @since Ant 1.2
    */
   public class ExecuteJava implements Runnable, TimeoutObserver {
   
  
  
  
  1.39      +40 -21    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java
  
  Index: Java.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Java.java	8 Apr 2002 15:40:33 -0000	1.38
  +++ Java.java	11 Apr 2002 14:58:00 -0000	1.39
  @@ -72,12 +72,15 @@
   import java.util.Vector;
   
   /**
  - * This task acts as a loader for java applications but allows to use the same JVM 
  - * for the called application thus resulting in much faster operation.
  + * This task acts as a loader for java applications but allows to use
  + * the same JVM for the called application thus resulting in much
  + * faster operation.
    *
    * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a>
    * @author <a href="mailto:stefan.bodewig@epost.de">Stefan Bodewig</a>
    *
  + * @since Ant 1.1
  + *
    * @ant.task category="java"
    */
   public class Java extends Task {
  @@ -97,14 +100,19 @@
        * Do the execution.
        */
       public void execute() throws BuildException {
  -        int err = -1;
  +        File savedDir = dir;
   
  -        if ((err = executeJava()) != 0) { 
  -            if (failOnError) {
  -                throw new BuildException("Java returned: "+err, location);
  -            } else {
  -                log("Java Result: " + err, Project.MSG_ERR);
  +        int err = -1;
  +        try {
  +            if ((err = executeJava()) != 0) { 
  +                if (failOnError) {
  +                    throw new BuildException("Java returned: "+err, location);
  +                } else {
  +                    log("Java Result: " + err, Project.MSG_ERR);
  +                }
               }
  +        } finally {
  +            dir = savedDir;
           }
       }
   
  @@ -200,7 +208,8 @@
        */
       public void setJar(File jarfile) throws BuildException {
           if ( cmdl.getClassname() != null ){
  -            throw new BuildException("Cannot use 'jar' and 'classname' attributes in same
command.");
  +            throw new BuildException("Cannot use 'jar' and 'classname' "
  +                                     + "attributes in same command.");
           }
           cmdl.setJar(jarfile.getAbsolutePath());
       }
  @@ -210,7 +219,8 @@
        */
       public void setClassname(String s) throws BuildException {
           if ( cmdl.getJar() != null ){
  -            throw new BuildException("Cannot use 'jar' and 'classname' attributes in same
command");
  +            throw new BuildException("Cannot use 'jar' and 'classname' "
  +                                     + "attributes in same command");
           }
           cmdl.setClassname(s);
       }
  @@ -307,7 +317,7 @@
        *
        * <p>Will be ignored if we are not forking a new VM.
        *
  -     * @since 1.32, Ant 1.5
  +     * @since Ant 1.5
        */
       public void addEnv(Environment.Variable var) {
           env.addVariable(var);
  @@ -318,7 +328,7 @@
        *
        * <p>Will be ignored if we are not forking a new VM.
        *
  -     * @since 1.32, Ant 1.5
  +     * @since Ant 1.5
        */
       public void setNewenvironment(boolean newenv) {
           newEnvironment = newenv;
  @@ -327,7 +337,7 @@
       /**
        * Shall we append to an existing file?
        *
  -     * @since 1.36, Ant 1.5
  +     * @since Ant 1.5
        */
       public void setAppend(boolean append) {
           this.append = append;
  @@ -336,26 +346,34 @@
       /**
        * Timeout in milliseconds after which the process will be killed.
        *
  -     * @since 1.37, Ant 1.5
  +     * @since Ant 1.5
        */
       public void setTimeout(Long value) {
           timeout = value;
       }
   
  +    /**
  +     * Pass output sent to System.out to specified output file.
  +     *
  +     * @since Ant 1.5
  +     */
       protected void handleOutput(String line) {
           if (outStream != null) {
               outStream.println(line);
  -        }
  -        else {
  +        } else {
               super.handleOutput(line);
           }
       }
       
  +    /**
  +     * Pass output sent to System.err to specified output file.
  +     *
  +     * @since Ant 1.5
  +     */
       protected void handleErrorOutput(String line) {
           if (outStream != null) {
               outStream.println(line);
  -        }
  -        else {
  +        } else {
               super.handleErrorOutput(line);
           }
       }
  @@ -412,7 +430,8 @@
               if (dir == null) {
                   dir = project.getBaseDir();
               } else if (!dir.exists() || !dir.isDirectory()) {
  -                throw new BuildException(dir.getAbsolutePath()+" is not a valid directory",
  +                throw new BuildException(dir.getAbsolutePath()
  +                                         +" is not a valid directory",
                                            location);
               }
               
  @@ -470,11 +489,11 @@
       /**
        * Create the Watchdog to kill a runaway process.
        *
  -     * @since 1.37, Ant 1.5
  +     * @since Ant 1.5
        */
       protected ExecuteWatchdog createWatchdog() throws BuildException {
           if (timeout == null) {
  -          return null;
  +            return null;
           }
           return new ExecuteWatchdog(timeout.longValue());
       }
  
  
  

--
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