Index: test/java/org/apache/ivy/core/settings/ivysettings-environment.xml
===================================================================
--- test/java/org/apache/ivy/core/settings/ivysettings-environment.xml	(revision 0)
+++ test/java/org/apache/ivy/core/settings/ivysettings-environment.xml	(revision 0)
@@ -0,0 +1,21 @@
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one
+   or more contributor license agreements.  See the NOTICE file
+   distributed with this work for additional information
+   regarding copyright ownership.  The ASF licenses this file
+   to you under the Apache License, Version 2.0 (the
+   "License"); you may not use this file except in compliance
+   with the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing,
+   software distributed under the License is distributed on an
+   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+   KIND, either express or implied.  See the License for the
+   specific language governing permissions and limitations
+   under the License.    
+-->
+<ivysettings>
+    <properties environment="env"/>
+</ivysettings>
Index: test/java/org/apache/ivy/core/settings/environment/EnvironmentLoaderTest.java
===================================================================
--- test/java/org/apache/ivy/core/settings/environment/EnvironmentLoaderTest.java	(revision 0)
+++ test/java/org/apache/ivy/core/settings/environment/EnvironmentLoaderTest.java	(revision 0)
@@ -0,0 +1,42 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.core.settings.environment;
+
+import java.util.Map;
+
+import org.apache.commons.lang.SystemUtils;
+
+import junit.framework.TestCase;
+
+public class EnvironmentLoaderTest extends TestCase {
+    public void testGetEnvironment() throws Exception {
+        EnvironmentLoader envLoader = EnvironmentLoader.getInstance();
+        // this test needs to be run twice, once in Java 5, and the other in Java 1.4.
+        if (SystemUtils.JAVA_VERSION_FLOAT >= 1.5) {
+            assertTrue("Should have used Java5EnvironmentLoader in Java 5.",
+                       envLoader instanceof Java5EnvironmentLoader);
+        } else {
+            assertTrue("Should have used AntEnvironmentLoader when not in Java 5.",
+                       envLoader instanceof AntEnvironmentLoader);
+        }
+ 
+        Map env = envLoader.getEnvironment();
+        System.out.println(env);
+        assertNotNull("Expected 'env.PATH' to have some value.", env.get("PATH"));
+    }
+}
Index: test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
===================================================================
--- test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java	(revision 580659)
+++ test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java	(working copy)
@@ -23,6 +23,7 @@
 
 import junit.framework.TestCase;
 
+import org.apache.commons.lang.SystemUtils;
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.report.ResolveReport;
 import org.apache.ivy.plugins.latest.LatestRevisionStrategy;
@@ -365,6 +366,15 @@
             ModuleDescriptorParserRegistry.getInstance().getParsers()[0].getClass().getName());
     }
 
+    public void testImportEnv() throws Exception {
+        IvySettings settings = new IvySettings();
+        XmlSettingsParser parser = new XmlSettingsParser(settings);
+
+        parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-environment.xml"));
+
+        assertNotNull(settings.getVariable("env.PATH"));
+    }
+
     public void testOutputter() throws Exception {
         IvySettings settings = new IvySettings();
         XmlSettingsParser parser = new XmlSettingsParser(settings);
Index: src/java/org/apache/ivy/core/settings/environment/Java5EnvironmentLoader.java
===================================================================
--- src/java/org/apache/ivy/core/settings/environment/Java5EnvironmentLoader.java	(revision 0)
+++ src/java/org/apache/ivy/core/settings/environment/Java5EnvironmentLoader.java	(revision 0)
@@ -0,0 +1,43 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.core.settings.environment;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+
+/**
+ * Implements <code>EnvironmentLoader</code> using Java 5 API.
+ * 
+ * @author Jing Xue
+ */
+public class Java5EnvironmentLoader extends EnvironmentLoader {
+
+    /**
+     * Retrieves the environment variables using <code>System.getEnv()</code> (available in Java 5+).
+     * 
+     * @see org.apache.ivy.core.settings.environment.EnvironmentLoader#getEnvironment()
+     * @see java.lang.System#getenv()
+     */
+    public Map getEnvironment() throws Exception {
+        // this can be updated to directly invoking the method once this class is moved
+        // into a separated source directory as Xavier suggested, and the conditional compilation
+        // Jan suggested is implemented.
+        Method getEnvMethod = System.class.getMethod("getenv", new Class[0]);
+        return (Map)getEnvMethod.invoke(null, null);
+    }
+}
Index: src/java/org/apache/ivy/core/settings/environment/EnvironmentLoader.java
===================================================================
--- src/java/org/apache/ivy/core/settings/environment/EnvironmentLoader.java	(revision 0)
+++ src/java/org/apache/ivy/core/settings/environment/EnvironmentLoader.java	(revision 0)
@@ -0,0 +1,52 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.core.settings.environment;
+
+import java.util.Map;
+
+import org.apache.ivy.util.Message;
+
+/**
+ * @author Jing Xue
+ */
+public abstract class EnvironmentLoader {
+    public static final String ANT_EXECUTE_CLASS = "org.apache.tools.ant.taskdefs.Execute";
+    public static final String JAVA5_GETENV_METHOD = "getenv";
+
+    public static EnvironmentLoader getInstance() {
+        try {
+            System.class.getMethod(JAVA5_GETENV_METHOD, new Class[0]);
+            Message.verbose("System." + JAVA5_GETENV_METHOD + "() found. Use "
+                + Java5EnvironmentLoader.class);
+            return new Java5EnvironmentLoader();
+        } catch (NoSuchMethodException nsme) {
+            Message.verbose("System." + JAVA5_GETENV_METHOD + "() not found. Checking if Ant is available.");
+            try {
+                Class.forName(ANT_EXECUTE_CLASS);
+                Message.verbose(ANT_EXECUTE_CLASS + " found. Use "
+                    + AntEnvironmentLoader.class);
+                return new AntEnvironmentLoader();
+            } catch (ClassNotFoundException cnfe) {
+                Message.verbose(ANT_EXECUTE_CLASS + " not found.");
+                throw new UnsupportedOperationException("Environment importing is only supported when running in Java 5 or with Ant.");
+            }
+        }
+    }
+
+    public abstract Map getEnvironment() throws Exception;
+}
Index: src/java/org/apache/ivy/core/settings/environment/AntEnvironmentLoader.java
===================================================================
--- src/java/org/apache/ivy/core/settings/environment/AntEnvironmentLoader.java	(revision 0)
+++ src/java/org/apache/ivy/core/settings/environment/AntEnvironmentLoader.java	(revision 0)
@@ -0,0 +1,58 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.ivy.core.settings.environment;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ivy.util.Message;
+
+/**
+ * Implements <code>EnvironmentLoader</code> leveraging Ant's facilities.
+ * 
+ * @author Jing Xue
+ */
+public class AntEnvironmentLoader extends EnvironmentLoader {
+
+    /**
+     * Returns environment variables using Ant's <code>Execute</code> task implementation.
+     * 
+     * @see org.apache.ivy.core.settings.environment.EnvironmentLoader#getEnvironment()
+     */
+    public Map getEnvironment() throws Exception {
+        // borrowed from Ant's Property.loadEnvironment() implementation,
+        // and brought up to JDK 1.4 compliant.
+        Map env = new HashMap();
+        Method getEnvMethod = Class.forName(ANT_EXECUTE_CLASS).getMethod("getProcEnvironment", null);
+ 
+        List osEnv = (List)getEnvMethod.invoke(null, null);
+        for (Iterator iEntry = osEnv.iterator(); iEntry.hasNext();) {
+            String entry = (String) iEntry.next();
+            int pos = entry.indexOf('=');
+            if (pos > 0) {
+                env.put(entry.substring(0, pos).trim(), entry.substring(pos + 1).trim());
+            } else {
+                Message.verbose("Ignoring environment line: " + entry);
+            }
+        }
+        return env;
+    }
+}
Index: src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
===================================================================
--- src/java/org/apache/ivy/core/settings/XmlSettingsParser.java	(revision 580659)
+++ src/java/org/apache/ivy/core/settings/XmlSettingsParser.java	(working copy)
@@ -32,6 +32,7 @@
 
 import org.apache.ivy.core.module.id.ModuleId;
 import org.apache.ivy.core.module.status.StatusManager;
+import org.apache.ivy.core.settings.environment.EnvironmentLoader;
 import org.apache.ivy.plugins.circular.CircularDependencyStrategy;
 import org.apache.ivy.plugins.conflict.ConflictManager;
 import org.apache.ivy.plugins.latest.LatestStrategy;
@@ -214,24 +215,46 @@
                 ivy.setVariable(name, value, override == null ? true : Boolean.valueOf(override)
                         .booleanValue());
             } else if ("properties".equals(qName)) {
+                String overrideStr = ivy.substitute((String) attributes.get("override"));
+                boolean override = overrideStr == null ? true: Boolean.valueOf(overrideStr).booleanValue();
+ 
+                String envPrefix = ivy.substitute((String) attributes.get("environment"));
+                if (envPrefix != null) {
+                    // append a dot only if the specified prefix doesn't have one. this is
+                    // compatible with ant's behavior.
+                    if (!envPrefix.endsWith(".")) {
+                        envPrefix += '.';
+                    }
+
+                    Map env;
+                    try {
+                        env = EnvironmentLoader.getInstance().getEnvironment();
+                    } catch (Exception e) {
+                        throw new IllegalArgumentException("Unable to import environment variables: " + e);
+                    }
+                    for (Iterator iterator = env.entrySet().iterator(); iterator.hasNext();) {
+                        Map.Entry entry = (Map.Entry) iterator.next();
+                        ivy.setVariable(envPrefix + entry.getKey(), (String)entry.getValue(), override);
+                    }
+                }
+
                 String propFilePath = ivy.substitute((String) attributes.get("file"));
-                String override = ivy.substitute((String) attributes.get("override"));
-                try {
-                    Message.verbose("loading properties: " + propFilePath);
-                    ivy.loadProperties(new File(propFilePath), override == null ? true : Boolean
-                            .valueOf(override).booleanValue());
-                } catch (Exception fileEx) {
-                    Message.verbose("failed to load properties as file: trying as url: "
-                            + propFilePath);
+                if (propFilePath != null) {
                     try {
-                        ivy.loadProperties(new URL(propFilePath), override == null ? true : Boolean
-                                .valueOf(override).booleanValue());
-                    } catch (Exception urlEx) {
-                        throw new IllegalArgumentException(
-                                "unable to load properties from "
-                                        + propFilePath
-                                        + ". Tried both as an url and a file, with no success. File exception: "
-                                        + fileEx + ". URL exception: " + urlEx);
+                        Message.verbose("loading properties: " + propFilePath);
+                        ivy.loadProperties(new File(propFilePath), override);
+                    } catch (Exception fileEx) {
+                        Message.verbose("failed to load properties as file: trying as url: "
+                                + propFilePath);
+                        try {
+                            ivy.loadProperties(new URL(propFilePath), override);
+                        } catch (Exception urlEx) {
+                            throw new IllegalArgumentException(
+                                    "unable to load properties from "
+                                            + propFilePath
+                                            + ". Tried both as an url and a file, with no success. File exception: "
+                                            + fileEx + ". URL exception: " + urlEx);
+                        }
                     }
                 }
             } else if ("include".equals(qName)) {
Index: doc/configuration/properties.html
===================================================================
--- doc/configuration/properties.html	(revision 580659)
+++ doc/configuration/properties.html	(working copy)
@@ -35,7 +35,9 @@
 </thead>
 <tbody>
     <tr><td>file</td><td>a path to a properties file to load</td>
-        <td>Yes</td></tr>
+        <td>Either 'file' or 'environment'</td></tr>
+    <tr><td>environment</td><td>indicates to import environment variables as properties (similar to the environment importing provided by Ant 'property' task). The value is appended to the names of the properties imported. <span class="since">since 2.0</span></td>
+        <td>Either 'file' or 'environment'</td></tr>
     <tr><td>override</td><td>indicates if the variable found in the properties file should override their previous value, if any <span class="since">since 1.3</span></td>
         <td>No, defaults to true</td></tr>
 </tbody>
