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/taskdefs Property.java
Date Sat, 22 Dec 2001 13:00:02 GMT
donaldp     01/12/22 05:00:02

  Modified:    proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs
                        Property.java
  Log:
  load environment data from new Environment class.
  
  Revision  Changes    Path
  1.14      +25 -17    jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java
  
  Index: Property.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/Property.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Property.java	2001/12/21 14:21:19	1.13
  +++ Property.java	2001/12/22 13:00:02	1.14
  @@ -11,15 +11,14 @@
   import java.io.FileInputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.util.Enumeration;
   import java.util.Iterator;
   import java.util.Properties;
  -import java.util.ArrayList;
  -import java.util.Enumeration;
   import org.apache.myrmidon.api.TaskException;
  +import org.apache.myrmidon.framework.exec.Environment;
   import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.taskdefs.exec.Execute;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   
  @@ -210,25 +209,34 @@
       protected void loadEnvironment( String prefix )
           throws TaskException
       {
  -        Properties props = new Properties();
  +        final Properties props = new Properties();
           if( !prefix.endsWith( "." ) )
               prefix += ".";
  -        log( "Loading Environment " + prefix, Project.MSG_VERBOSE );
  -        ArrayList osEnv = Execute.getProcEnvironment();
  -        for( Iterator e = osEnv.iterator(); e.hasNext(); )
  -        {
  -            String entry = (String)e.next();
  -            int pos = entry.indexOf( '=' );
  -            if( pos == -1 )
  -            {
  -                log( "Ignoring: " + entry, Project.MSG_WARN );
  -            }
  -            else
  +
  +        log( "Loading EnvironmentData " + prefix, Project.MSG_VERBOSE );
  +        try
  +        {
  +            final Properties environment = Environment.getNativeEnvironment();
  +            for( Iterator e = environment.keySet().iterator(); e.hasNext(); )
               {
  -                props.put( prefix + entry.substring( 0, pos ),
  -                           entry.substring( pos + 1 ) );
  +                final String key = (String)e.next();
  +                final String value = environment.getProperty( key );
  +
  +                if( value.equals( "" ) )
  +                {
  +                    log( "Ignoring: " + key, Project.MSG_WARN );
  +                }
  +                else
  +                {
  +                    props.put( prefix + key, value );
  +                }
               }
           }
  +        catch( final IOException ioe )
  +        {
  +            throw new TaskException( ioe.getMessage(), ioe );
  +        }
  +
           addProperties( props );
       }
   
  
  
  

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