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 Java.java
Date Thu, 27 Jan 2000 03:53:24 GMT
stefano     00/01/26 19:53:24

  Modified:    src/main/org/apache/tools/ant/taskdefs Java.java
  Log:
  added ability to fork the JVM for those processes that call System.exit(), also added the
JVM arguments
  
  Revision  Changes    Path
  1.2       +38 -7     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Java.java	2000/01/13 10:41:41	1.1
  +++ Java.java	2000/01/27 03:53:24	1.2
  @@ -64,10 +64,12 @@
    *
    * @author Stefano Mazzocchi <a href="mailto:stefano@pache.org">stefano@apache.org</a>
    */
  -public class Java extends Task {
  +public class Java extends Exec {
   
       private String classname = null;
       private String args = null;
  +    private String jvmargs = null;
  +    private boolean fork = false;
       
       /**
        * Do the execution.
  @@ -75,16 +77,31 @@
       public void execute() throws BuildException {
           
           project.log("Calling " + classname, "java", project.MSG_VERBOSE);
  -        
  +
           if (classname == null) {
               throw new BuildException("Class name must not be null.");
           }
   
  -        Vector argList = tokenize(args);
  -        
  -        project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE);
  -        
  -        run(classname, argList);
  +        if (fork) {
  +            StringBuffer b = new StringBuffer();
  +            b.append("java ");
  +            if (jvmargs != null) {
  +                b.append(jvmargs);
  +                b.append(" ");
  +            }
  +            b.append(classname);
  +            if (args != null) {
  +                b.append(" ");
  +                b.append(args);
  +            }
  +            
  +            run(b.toString());
  +        } else {
  +            Vector argList = tokenize(args);
  +            if (jvmargs != null) project.log("JVM args ignored when same JVM is used.",
"java", project.MSG_VERBOSE);
  +            project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE);
  +            run(classname, argList);
  +        }
       }
       
       /**
  @@ -101,6 +118,20 @@
           this.args = s;
       }
   
  +    /**
  +     * Set the forking flag.
  +     */
  +    public void setFork(String s) {
  +        this.fork = Project.toBoolean(s);
  +    }
  +
  +    /**
  +     * Set the jvm arguments.
  +     */
  +    public void setJvmargs(String s) {
  +        this.jvmargs = s;
  +    }
  +        
       /**
        * Executes the given classname with the given arguments as it
        * was a command line application.
  
  
  

Mime
View raw message