ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/types CommandlineJava.java
Date Thu, 02 Aug 2001 14:38:46 GMT
conor       01/08/02 07:38:46

  Modified:    src/main/org/apache/tools/ant/taskdefs Java.java
               src/main/org/apache/tools/ant/types CommandlineJava.java
  Log:
  Add jvmVersion attribute so that maxmeory is formatted correctly for the
  target JVM
  
  PR:	2913
  
  Revision  Changes    Path
  1.28      +5 -5      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.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Java.java	2001/07/22 15:44:11	1.27
  +++ Java.java	2001/08/02 14:38:46	1.28
  @@ -239,13 +239,13 @@
        * -mx or -Xmx depending on VM version
        */
       public void setMaxmemory(String max){
  -        if (Project.getJavaVersion().startsWith("1.1")) {
  -            createJvmarg().setValue("-mx"+max);
  -        } else {
  -            createJvmarg().setValue("-Xmx"+max);
  -        }
  +        cmdl.setMaxmemory(max);
       }
   
  +    public void setJVMVersion(String value) {
  +        cmdl.setVmversion(value);
  +    }
  +    
       protected void handleOutput(String line) {
           if (outStream != null) {
               outStream.println(line);
  
  
  
  1.14      +29 -7     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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CommandlineJava.java	2001/07/18 10:07:02	1.13
  +++ CommandlineJava.java	2001/08/02 14:38:46	1.14
  @@ -69,6 +69,7 @@
       private SysProperties sysProperties = new SysProperties();
       private Path classpath = null;
       private String vmVersion;
  +    private String maxMemory = null;
   
       /**
        * Specialized Environment class for System properties
  @@ -129,7 +130,7 @@
   
       public CommandlineJava() {
           setVm(getJavaExecutableName());
  -        setVmversion(org.apache.tools.ant.Project.getJavaVersion());
  +        setVmversion(Project.getJavaVersion());
       }
   
       public Commandline.Argument createArgument() {
  @@ -173,17 +174,18 @@
   
       public String[] getCommandline() {
           Path fullClasspath = classpath != null ? classpath.concatSystemClasspath("ignore")
: null;
  +        Commandline actualVMCommand = getActualVMCommand();
           int size = 
  -            vmCommand.size() + javaCommand.size() + sysProperties.size();
  +            actualVMCommand.size() + javaCommand.size() + sysProperties.size();
           if (fullClasspath != null && fullClasspath.size() > 0) {
               size += 2;
           }
           
           String[] result = new String[size];
  -        System.arraycopy(vmCommand.getCommandline(), 0, 
  -                         result, 0, vmCommand.size());
  +        System.arraycopy(actualVMCommand.getCommandline(), 0, 
  +                         result, 0, actualVMCommand.size());
   
  -        int pos = vmCommand.size();
  +        int pos = actualVMCommand.size();
           if (sysProperties.size() > 0) {
               System.arraycopy(sysProperties.getVariables(), 0,
                                result, pos, sysProperties.size());
  @@ -198,13 +200,32 @@
           return result;
       }
   
  +    /**
  +     * -mx or -Xmx depending on VM version
  +     */
  +    public void setMaxmemory(String max){
  +        this.maxMemory = max;
  +    }
   
  +
       public String toString() {
           return Commandline.toString(getCommandline());
       }
   
  +    private Commandline getActualVMCommand() {
  +        Commandline actualVMCommand = (Commandline)vmCommand.clone();
  +        if (maxMemory != null) {
  +            if (vmVersion.startsWith("1.1")) {
  +                actualVMCommand.createArgument().setValue("-mx" + maxMemory);
  +            } else {
  +                actualVMCommand.createArgument().setValue("-Xmx" + maxMemory);
  +            }
  +        }
  +        return actualVMCommand;
  +    }        
  +    
       public int size() {
  -        int size = vmCommand.size() + javaCommand.size();
  +        int size = getActualVMCommand().size() + javaCommand.size();
           if (classpath != null && classpath.size() > 0) {
               size += 2;
           }
  @@ -216,7 +237,7 @@
       }
   
       public Commandline getVmCommand() {
  -        return vmCommand;
  +        return getActualVMCommand();
       }
   
       public Path getClasspath() {
  @@ -240,6 +261,7 @@
           c.vmCommand = (Commandline) vmCommand.clone();
           c.javaCommand = (Commandline) javaCommand.clone();
           c.sysProperties = (SysProperties) sysProperties.clone();
  +        c.maxMemory = maxMemory;
           if (classpath != null) {
               c.classpath = (Path) classpath.clone();
           }
  
  
  

Mime
View raw message