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 DefaultCommandLauncher.java ExecUtil.java MacCommandLauncher.java ScriptCommandLauncher.java WinNTCommandLauncher.java
Date Sun, 23 Dec 2001 02:54:35 GMT
donaldp     01/12/22 18:54:35

  Modified:    proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers
                        DefaultCommandLauncher.java ExecUtil.java
                        MacCommandLauncher.java ScriptCommandLauncher.java
                        WinNTCommandLauncher.java
  Log:
  Made ExecMetaData take a Properties object for environment data rather than native format.
  
  Revision  Changes    Path
  1.4       +5 -4      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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultCommandLauncher.java	2001/12/22 23:54:57	1.3
  +++ DefaultCommandLauncher.java	2001/12/23 02:54:35	1.4
  @@ -22,7 +22,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.3 $ $Date: 2001/12/22 23:54:57 $
  + * @version $Revision: 1.4 $ $Date: 2001/12/23 02:54:35 $
    */
   public class DefaultCommandLauncher
       implements CommandLauncher
  @@ -64,8 +64,8 @@
       {
           if( ExecUtil.isCwd( metaData.getWorkingDirectory() ) )
           {
  -            return Runtime.getRuntime().
  -                exec( metaData.getCommand(), metaData.getEnvironment() );
  +            final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment()
);
  +            return Runtime.getRuntime().exec( metaData.getCommand(), env );
           }
           else if( null == c_execWithCWD )
           {
  @@ -87,9 +87,10 @@
       private Process execJava13( final ExecMetaData metaData )
           throws IOException, ExecException
       {
  +        final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment() );
           final Object[] args =
               {metaData.getCommand(),
  -             metaData.getEnvironment(),
  +             env,
                metaData.getWorkingDirectory()};
           try
           {
  
  
  
  1.3       +11 -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.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExecUtil.java	2001/12/22 12:36:45	1.2
  +++ ExecUtil.java	2001/12/23 02:54:35	1.3
  @@ -9,13 +9,16 @@
   
   import java.io.File;
   import java.io.IOException;
  +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;
   
   /**
    * A set of utility functions useful when writing CommandLaunchers.
    *
    * @author <a href="mailto:peter@apache.org">Peter Donald</a>
  - * @version $Revision: 1.2 $ $Date: 2001/12/22 12:36:45 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/23 02:54:35 $
    */
   class ExecUtil
   {
  @@ -72,6 +75,13 @@
           throws IOException
       {
           return file.getCanonicalFile().equals( getCwd() );
  +    }
  +
  +    protected static String[] toNativeEnvironment( final Properties environment )
  +        throws ExecException
  +    {
  +        if( null == environment ) return null;
  +        else { return Environment.toNativeFormat( environment ); }
       }
   
       /**
  
  
  
  1.3       +5 -5      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/MacCommandLauncher.java
  
  Index: MacCommandLauncher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/MacCommandLauncher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MacCommandLauncher.java	2001/12/22 23:54:57	1.2
  +++ MacCommandLauncher.java	2001/12/23 02:54:35	1.3
  @@ -22,7 +22,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.2 $ $Date: 2001/12/22 23:54:57 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/23 02:54:35 $
    */
   public class MacCommandLauncher
       implements CommandLauncher
  @@ -36,8 +36,8 @@
           final File directory = metaData.getWorkingDirectory().getCanonicalFile();
           if( ExecUtil.isCwd( directory ) )
           {
  -            return Runtime.getRuntime().
  -                exec( metaData.getCommand(), metaData.getEnvironment() );
  +            final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment()
);
  +            return Runtime.getRuntime().exec( metaData.getCommand(), env );
           }
   
           //WARNING: This is an ugly hack and not thread safe in the slightest way
  @@ -46,8 +46,8 @@
           try
           {
               System.setProperty( "user.dir", directory.toString() );
  -            return Runtime.getRuntime().
  -                exec( metaData.getCommand(), metaData.getEnvironment() );
  +            final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment()
);
  +            return Runtime.getRuntime().exec( metaData.getCommand(), env );
           }
           finally
           {
  
  
  
  1.4       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/ScriptCommandLauncher.java
  
  Index: ScriptCommandLauncher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/ScriptCommandLauncher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ScriptCommandLauncher.java	2001/12/22 23:54:57	1.3
  +++ ScriptCommandLauncher.java	2001/12/23 02:54:35	1.4
  @@ -20,7 +20,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.3 $ $Date: 2001/12/22 23:54:57 $
  + * @version $Revision: 1.4 $ $Date: 2001/12/23 02:54:35 $
    */
   public class ScriptCommandLauncher
       implements CommandLauncher
  @@ -70,7 +70,7 @@
           prefix[ m_script.length ] = metaData.getWorkingDirectory().getCanonicalPath();
   
           final ExecMetaData newMetaData = ExecUtil.prepend( metaData, prefix );
  -        return Runtime.getRuntime().
  -            exec( newMetaData.getCommand(), newMetaData.getEnvironment() );
  +        final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment() );
  +        return Runtime.getRuntime().exec( newMetaData.getCommand(), env );
       }
   }
  
  
  
  1.3       +3 -3      jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/WinNTCommandLauncher.java
  
  Index: WinNTCommandLauncher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/java/org/apache/myrmidon/framework/exec/launchers/WinNTCommandLauncher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WinNTCommandLauncher.java	2001/12/22 23:54:57	1.2
  +++ WinNTCommandLauncher.java	2001/12/23 02:54:35	1.3
  @@ -18,7 +18,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.2 $ $Date: 2001/12/22 23:54:57 $
  + * @version $Revision: 1.3 $ $Date: 2001/12/23 02:54:35 $
    */
   public class WinNTCommandLauncher
       implements CommandLauncher
  @@ -41,7 +41,7 @@
           prefix[ 5 ] = "&&";
   
           final ExecMetaData newMetaData = ExecUtil.prepend( metaData, prefix );
  -        return Runtime.getRuntime().
  -            exec( newMetaData.getCommand(), newMetaData.getEnvironment() );
  +        final String[] env = ExecUtil.toNativeEnvironment( metaData.getEnvironment() );
  +        return Runtime.getRuntime().exec( newMetaData.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