From 881bb9c42a84b630f776a222f073416e8f81b7b0 Mon Sep 17 00:00:00 2001 From: john lilley Date: Mon, 5 Aug 2024 13:08:50 -0600 Subject: [PATCH] Do not get UPPERCASE env vars (#427) * Do not get UPPERCASE env vars * PR feedback: use System.getenv() * Copy immutable env map * remove unused import --------- Co-authored-by: John Lilley --- src/main/java/org/codehaus/mojo/exec/ExecMojo.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java index 18321408..723c3fb8 100644 --- a/src/main/java/org/codehaus/mojo/exec/ExecMojo.java +++ b/src/main/java/org/codehaus/mojo/exec/ExecMojo.java @@ -36,7 +36,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Properties; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; @@ -476,13 +475,11 @@ public void execute() throws MojoExecutionException { } private Map handleSystemEnvVariables() throws MojoExecutionException { - - Map enviro = new HashMap<>(); - Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); - for (Map.Entry entry : systemEnvVars.entrySet()) { - enviro.put((String) entry.getKey(), (String) entry.getValue()); - } - + // Avoid creating env vars that differ only in case on Windows. + // https://github.com/mojohaus/exec-maven-plugin/issues/328 + // It is not enough to avoid duplicates; we must preserve the case found in the "natural" environment. + // https://developercommunity.visualstudio.com/t/Build-Error:-MSB6001-in-Maven-Build/10527486?sort=newest + Map enviro = new HashMap<>(System.getenv()); if (environmentVariables != null) { enviro.putAll(environmentVariables); }