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/types CommandlineJava.java
Date Sat, 02 Feb 2002 12:29:25 GMT
sbailliez    02/02/02 04:29:25

  Modified:    src/testcases/org/apache/tools/ant/types
                        CommandlineJavaTest.java
               src/main/org/apache/tools/ant/types CommandlineJava.java
  Log:
  Fix -jar option to be appended rather than prepended
  as specified in usage command line since the parsing
  for jvmtype is broken in JDK < 1.4.0.
  I filled bugs 139128 and 139129 to Sun for this.
  Reported by: christophe.aubry@temis-group.com (Christophe Aubry)
  PR: 5307
  
  Revision  Changes    Path
  1.10      +14 -0     jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java
  
  Index: CommandlineJavaTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/testcases/org/apache/tools/ant/types/CommandlineJavaTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CommandlineJavaTest.java	10 Jan 2002 10:13:13 -0000	1.9
  +++ CommandlineJavaTest.java	2 Feb 2002 12:29:24 -0000	1.10
  @@ -120,4 +120,18 @@
                        "org.apache.tools.ant.CommandlineJavaTest", s[5]);
       }
   
  +    public void testJarOption() throws Exception {
  +        CommandlineJava c = new CommandlineJava();
  +        c.createArgument().setValue("arg1");
  +        c.setJar("myfile.jar");
  +        c.createVmArgument().setValue("-classic");
  +        c.createVmArgument().setValue("-Dx=y");
  +        String[] s = c.getCommandline();
  +        assertEquals("-classic", s[1]);
  +        assertEquals("-Dx=y", s[2]);
  +        assertEquals("-jar", s[3]);
  +        assertEquals("myfile.jar", s[4]);
  +        assertEquals("arg1", s[5]);
  +    }
  +
   }
  
  
  
  1.27      +11 -5     jakarta-ant/src/main/org/apache/tools/ant/types/CommandlineJava.java
  
  Index: CommandlineJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- CommandlineJava.java	26 Jan 2002 20:16:22 -0000	1.26
  +++ CommandlineJava.java	2 Feb 2002 12:29:24 -0000	1.27
  @@ -69,7 +69,7 @@
    * a java command line.
    *
    * @author thomas.haas@softwired-inc.com
  - * @author <a href="sbailliez@apache.org">Stephane Bailliez</a>
  + * @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
    */
   public class CommandlineJava implements Cloneable {
   
  @@ -234,10 +234,6 @@
           // first argument is the java.exe path...
           result[pos++] = vmArgs[0];
           
  -        // -jar must be the first option in the command line.
  -        if (executeJar){
  -            result[pos++] = "-jar";
  -        }
           // next follows the vm options
           System.arraycopy(vmArgs, 1, result, pos, vmArgs.length - 1);
           pos += vmArgs.length - 1;
  @@ -253,10 +249,20 @@
               result[pos++] = "-classpath";
               result[pos++] = fullClasspath.toString();
           }
  +
  +        // JDK usage command line says that -jar must be the first option, as there is
  +        // a bug in JDK < 1.4 that forces the jvm type to be specified as the first
  +        // option, it is appended here as specified in the docs even though there is
  +        // in fact no order.
  +        if (executeJar){
  +            result[pos++] = "-jar";
  +        }
  +
           // this is the classname to run as well as its arguments.
           // in case of 'executeJar', the executable is a jar file.
           System.arraycopy(javaCommand.getCommandline(), 0, 
                            result, pos, javaCommand.size());
  +
           return result;
       }
   
  
  
  

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