ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types SysProperties.java CommandlineJava.java
Date Sun, 30 Dec 2001 06:46:37 GMT
donaldp     01/12/29 22:46:37

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        ExecuteJava.java
               proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit
                        JUnitTask.java
               proposal/myrmidon/src/main/org/apache/tools/ant/types
                        CommandlineJava.java
  Added:       proposal/myrmidon/src/main/org/apache/tools/ant/types
                        SysProperties.java
  Log:
  Made SysProeprties a top level class.
  
  Revision  Changes    Path
  1.7       +3 -2      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  
  Index: ExecuteJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ExecuteJava.java	30 Dec 2001 03:33:58 -0000	1.6
  +++ ExecuteJava.java	30 Dec 2001 06:46:37 -0000	1.7
  @@ -16,6 +16,7 @@
   import org.apache.tools.ant.types.Commandline;
   import org.apache.tools.ant.types.CommandlineJava;
   import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.types.SysProperties;
   
   /*
    * @author thomas.haas@softwired-inc.com
  @@ -25,7 +26,7 @@
   {
       private Commandline m_javaCommand;
       private Path m_classpath;
  -    private CommandlineJava.SysProperties m_sysProperties;
  +    private SysProperties m_sysProperties;
   
       public void setClasspath( final Path classpath )
       {
  @@ -37,7 +38,7 @@
           m_javaCommand = javaCommand;
       }
   
  -    public void setSystemProperties( final CommandlineJava.SysProperties sysProperties
)
  +    public void setSystemProperties( final SysProperties sysProperties )
       {
           m_sysProperties = sysProperties;
       }
  
  
  
  1.21      +2 -1      jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
  
  Index: JUnitTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- JUnitTask.java	30 Dec 2001 03:33:58 -0000	1.20
  +++ JUnitTask.java	30 Dec 2001 06:46:37 -0000	1.21
  @@ -28,6 +28,7 @@
   import org.apache.tools.ant.types.EnumeratedAttribute;
   import org.apache.tools.ant.types.EnvironmentVariable;
   import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.types.SysProperties;
   
   /**
    * Ant task to run JUnit tests. <p>
  @@ -686,7 +687,7 @@
               getLogger().warn( "dir attribute ignored if running in the same VM" );
           }
   
  -        CommandlineJava.SysProperties sysProperties = commandline.getSystemProperties();
  +        SysProperties sysProperties = commandline.getSystemProperties();
           if( sysProperties != null )
           {
               sysProperties.setSystem();
  
  
  
  1.12      +0 -95     jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java
  
  Index: CommandlineJava.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CommandlineJava.java	30 Dec 2001 01:14:59 -0000	1.11
  +++ CommandlineJava.java	30 Dec 2001 06:46:37 -0000	1.12
  @@ -7,13 +7,8 @@
    */
   package org.apache.tools.ant.types;
   
  -import java.util.ArrayList;
  -import java.util.Iterator;
  -import java.util.Properties;
   import org.apache.myrmidon.api.TaskException;
   import org.apache.myrmidon.framework.Os;
  -import org.apache.myrmidon.framework.exec.Environment;
  -import org.apache.myrmidon.framework.exec.ExecException;
   import org.apache.tools.ant.Project;
   
   /**
  @@ -301,96 +296,6 @@
           {
               return "java";
           }
  -    }
  -
  -    /**
  -     * Specialized EnvironmentData class for System properties
  -     *
  -     * @author RT
  -     */
  -    public static class SysProperties extends EnvironmentData implements Cloneable
  -    {
  -        Properties sys = null;
  -
  -        public void setSystem()
  -            throws TaskException
  -        {
  -            try
  -            {
  -                Properties p = new Properties( sys = System.getProperties() );
  -
  -                for( Iterator e = m_variables.iterator(); e.hasNext(); )
  -                {
  -                    EnvironmentVariable v = (EnvironmentVariable)e.next();
  -                    p.put( v.getKey(), v.getValue() );
  -                }
  -                System.setProperties( p );
  -            }
  -            catch( SecurityException e )
  -            {
  -                throw new TaskException( "Cannot modify system properties", e );
  -            }
  -        }
  -
  -        public String[] getJavaVariables()
  -            throws TaskException
  -        {
  -            String props[] = new String[ 0 ];
  -            try
  -            {
  -                props = Environment.toNativeFormat( super.getVariables() );
  -            }
  -            catch( final ExecException ee )
  -            {
  -                throw new TaskException( ee.getMessage(), ee );
  -            }
  -
  -            if( props == null )
  -                return null;
  -
  -            for( int i = 0; i < props.length; i++ )
  -            {
  -                props[ i ] = "-D" + props[ i ];
  -            }
  -            return props;
  -        }
  -
  -        public Object clone()
  -        {
  -            try
  -            {
  -                SysProperties c = (SysProperties)super.clone();
  -                c.m_variables.addAll( (ArrayList)m_variables.clone() );
  -                return c;
  -            }
  -            catch( CloneNotSupportedException e )
  -            {
  -                return null;
  -            }
  -        }
  -
  -        public void restoreSystem()
  -            throws TaskException
  -        {
  -            if( sys == null )
  -                throw new TaskException( "Unbalanced nesting of SysProperties" );
  -
  -            try
  -            {
  -                System.setProperties( sys );
  -                sys = null;
  -            }
  -            catch( SecurityException e )
  -            {
  -                throw new TaskException( "Cannot modify system properties", e );
  -            }
  -        }
  -
  -        public int size()
  -        {
  -            return m_variables.size();
  -        }
  -
       }
   
   }
  
  
  
  1.1                  jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/types/SysProperties.java
  
  Index: SysProperties.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included  with this distribution in
   * the LICENSE.txt file.
   */
  package org.apache.tools.ant.types;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.Properties;
  import org.apache.myrmidon.api.TaskException;
  import org.apache.myrmidon.framework.exec.ExecException;
  
  /**
   * Specialized EnvironmentData class for System properties
   */
  public class SysProperties
      extends EnvironmentData
      implements Cloneable
  {
      private Properties m_system;
  
      public void setSystem()
          throws TaskException
      {
          try
          {
              Properties p = new Properties( m_system = System.getProperties() );
  
              for( Iterator e = m_variables.iterator(); e.hasNext(); )
              {
                  EnvironmentVariable v = (EnvironmentVariable)e.next();
                  p.put( v.getKey(), v.getValue() );
              }
              System.setProperties( p );
          }
          catch( SecurityException e )
          {
              throw new TaskException( "Cannot modify system properties", e );
          }
      }
  
      public String[] getJavaVariables()
          throws TaskException
      {
          String props[] = new String[ 0 ];
          try
          {
              props = toNativeFormat( super.getVariables() );
          }
          catch( final ExecException ee )
          {
              throw new TaskException( ee.getMessage(), ee );
          }
  
          if( props == null )
              return null;
  
          for( int i = 0; i < props.length; i++ )
          {
              props[ i ] = "-D" + props[ i ];
          }
          return props;
      }
  
      public Object clone()
      {
          try
          {
              SysProperties c = (SysProperties)super.clone();
              c.m_variables.addAll( (ArrayList)m_variables.clone() );
              return c;
          }
          catch( CloneNotSupportedException e )
          {
              return null;
          }
      }
  
      public void restoreSystem()
          throws TaskException
      {
          if( m_system == null )
              throw new TaskException( "Unbalanced nesting of SysProperties" );
  
          try
          {
              System.setProperties( m_system );
              m_system = null;
          }
          catch( SecurityException e )
          {
              throw new TaskException( "Cannot modify system properties", e );
          }
      }
  
      public int size()
      {
          return m_variables.size();
      }
  
      private String[] toNativeFormat( final Properties environment )
          throws ExecException
      {
          final ArrayList newEnvironment = new ArrayList();
  
          final Iterator keys = environment.keySet().iterator();
          while( keys.hasNext() )
          {
              final String key = (String)keys.next();
              final String value = environment.getProperty( key );
              newEnvironment.add( key + '=' + value );
          }
  
          return (String[])newEnvironment.toArray( new String[ newEnvironment.size() ] );
      }
  }
  
  
  

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