Skip to content

Commit

Permalink
Do not get UPPERCASE env vars (#427)
Browse files Browse the repository at this point in the history
* Do not get UPPERCASE env vars

* PR feedback: use System.getenv()

* Copy immutable env map

* remove unused import

---------

Co-authored-by: John Lilley <john.lilley@redpoint.net>
  • Loading branch information
wheezil and John Lilley committed Aug 5, 2024
1 parent b2ba5ae commit 881bb9c
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/main/java/org/codehaus/mojo/exec/ExecMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -476,13 +475,11 @@ public void execute() throws MojoExecutionException {
}

private Map<String, String> handleSystemEnvVariables() throws MojoExecutionException {

Map<String, String> 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<String, String> enviro = new HashMap<>(System.getenv());
if (environmentVariables != null) {
enviro.putAll(environmentVariables);
}
Expand Down

0 comments on commit 881bb9c

Please sign in to comment.