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/java/org/apache/myrmidon/framework/exec/launchers ExecUtil.java DefaultCommandLauncher.java
Date Sat, 05 Jan 2002 03:13:04 GMT
donaldp     02/01/04 19:13:04

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers
                        ExecUtil.java DefaultCommandLauncher.java
  Log:
  Moved getEnvironmentSpec to ExecUtil
  
  Revision  Changes    Path
  1.6       +32 -1     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/ExecUtil.java
  
  Index: ExecUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/ExecUtil.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ExecUtil.java	30 Dec 2001 06:45:25 -0000	1.5
  +++ ExecUtil.java	5 Jan 2002 03:13:03 -0000	1.6
  @@ -12,6 +12,7 @@
   import java.util.ArrayList;
   import java.util.Iterator;
   import java.util.Properties;
  +import org.apache.myrmidon.framework.exec.Environment;
   import org.apache.myrmidon.framework.exec.ExecException;
   import org.apache.myrmidon.framework.exec.ExecMetaData;
   
  @@ -19,7 +20,7 @@
    * A set of utility functions useful when writing CommandLaunchers.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.5 $ $Date: 2001/12/30 06:45:25 $
  + * @version $Revision: 1.6 $ $Date: 2002/01/05 03:13:03 $
    */
   class ExecUtil
   {
  @@ -108,5 +109,35 @@
       protected static File getCwd()
       {
           return c_cwd;
  +    }
  +
  +    /**
  +     * Get the native environment according to proper rules.
  +     * Return null if no environment specified, return environment combined
  +     * with native environment if environment data is additive else just return
  +     * converted environment data.
  +     */
  +    protected static String[] getEnvironmentSpec( final ExecMetaData metaData )
  +        throws ExecException, IOException
  +    {
  +        final Properties environment = metaData.getEnvironment();
  +        if( 0 == environment.size() )
  +        {
  +            return null;
  +        }
  +        else
  +        {
  +            if( metaData.isEnvironmentAdditive() )
  +            {
  +                final Properties newEnvironment = new Properties();
  +                newEnvironment.putAll( Environment.getNativeEnvironment() );
  +                newEnvironment.putAll( environment );
  +                return toNativeEnvironment( newEnvironment );
  +            }
  +            else
  +            {
  +                return toNativeEnvironment( environment );
  +            }
  +        }
       }
   }
  
  
  
  1.7       +3 -33     jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/DefaultCommandLauncher.java
  
  Index: DefaultCommandLauncher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/DefaultCommandLauncher.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- DefaultCommandLauncher.java	5 Jan 2002 03:11:56 -0000	1.6
  +++ DefaultCommandLauncher.java	5 Jan 2002 03:13:03 -0000	1.7
  @@ -26,7 +26,7 @@
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
    * @author <a href="mailto:thomas.haas@softwired-inc.com">Thomas Haas</a>
  - * @version $Revision: 1.6 $ $Date: 2002/01/05 03:11:56 $
  + * @version $Revision: 1.7 $ $Date: 2002/01/05 03:13:03 $
    */
   public class DefaultCommandLauncher
       implements CommandLauncher
  @@ -71,7 +71,7 @@
       {
           if( ExecUtil.isCwd( metaData.getWorkingDirectory() ) )
           {
  -            final String[] env = getEnvironmentSpec( metaData );
  +            final String[] env = ExecUtil.getEnvironmentSpec( metaData );
               return Runtime.getRuntime().exec( metaData.getCommand(), env );
           }
           else if( null == c_execWithCWD )
  @@ -86,36 +86,6 @@
       }
   
       /**
  -     * Get the native environment according to proper rules.
  -     * Return null if no environment specified, return environment combined
  -     * with native environment if environment data is additive else just return
  -     * converted environment data.
  -     */
  -    private String[] getEnvironmentSpec( final ExecMetaData metaData )
  -        throws ExecException, IOException
  -    {
  -        final Properties environment = metaData.getEnvironment();
  -        if( 0 == environment.size() )
  -        {
  -            return null;
  -        }
  -        else
  -        {
  -            if( metaData.isEnvironmentAdditive() )
  -            {
  -                final Properties newEnvironment = new Properties();
  -                newEnvironment.putAll( Environment.getNativeEnvironment() );
  -                newEnvironment.putAll( environment );
  -                return ExecUtil.toNativeEnvironment( newEnvironment );
  -            }
  -            else
  -            {
  -                return ExecUtil.toNativeEnvironment( environment );
  -            }
  -        }
  -    }
  -
  -    /**
        * Execute the Java1.3 Runtime.exec() 3 parame method that sets working
        * directory. This needs to be done via reflection so that it can compile
        * under 1.2.
  @@ -123,7 +93,7 @@
       private Process execJava13( final ExecMetaData metaData )
           throws IOException, ExecException
       {
  -        final String[] env = getEnvironmentSpec( metaData );
  +        final String[] env = ExecUtil.getEnvironmentSpec( metaData );
           final Object[] args =
               {metaData.getCommand(),
                env,
  
  
  

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