diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index 30e3cf5028..757dec220e 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -16,7 +16,6 @@ package org.apache.maven.project.artifact; */ import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -25,10 +24,10 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.Set; -import java.util.Map.Entry; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.ArtifactUtils; @@ -70,7 +69,7 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.cli.CommandLineUtils; +import org.codehaus.plexus.util.Os; /** * @author Jason van Zyl @@ -704,17 +703,11 @@ public class MavenMetadataSource if ( envVars == null ) { Properties tmp = new Properties(); - try + boolean caseSensitive = !Os.isFamily( Os.FAMILY_WINDOWS ); + for ( Map.Entry entry : System.getenv().entrySet() ) { - Properties env = CommandLineUtils.getSystemEnvVars(); - for ( Entry e : env.entrySet() ) - { - tmp.setProperty( "env." + e.getKey().toString(), e.getValue().toString() ); - } - } - catch ( IOException e ) - { - logger.debug( "Error getting environment variables: " + e ); + String key = "env." + ( caseSensitive ? entry.getKey() : entry.getKey().toUpperCase( Locale.ENGLISH ) ); + tmp.setProperty( key, entry.getValue() ); } envVars = tmp; } diff --git a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java index e717c3dbc4..8e07dbc3ad 100644 --- a/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java @@ -17,16 +17,15 @@ package org.apache.maven.cli; import java.io.File; import java.io.FileNotFoundException; -import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Properties; import java.util.StringTokenizer; -import java.util.Map.Entry; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.ParseException; @@ -53,8 +52,8 @@ import org.codehaus.plexus.DefaultPlexusContainer; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.ClassWorld; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.util.Os; import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.cli.CommandLineUtils; import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; @@ -907,17 +906,11 @@ public class MavenCli { // add the env vars to the property set, with the "env." prefix // XXX support for env vars should probably be removed from the ModelInterpolator - try + boolean caseSensitive = !Os.isFamily( Os.FAMILY_WINDOWS ); + for ( Map.Entry entry : System.getenv().entrySet() ) { - Properties envVars = CommandLineUtils.getSystemEnvVars(); - for ( Entry e : envVars.entrySet() ) - { - systemProperties.setProperty( "env." + e.getKey().toString(), e.getValue().toString() ); - } - } - catch ( IOException e ) - { - System.err.println( "Error getting environment vars for profile activation: " + e ); + String key = "env." + ( caseSensitive ? entry.getKey() : entry.getKey().toUpperCase( Locale.ENGLISH ) ); + systemProperties.setProperty( key, entry.getValue() ); } // ----------------------------------------------------------------------