in daemon/src/main/java/org/mvndaemon/mvnd/cli/EnvHelper.java [53:95]
public static void environment(String workingDir, Map<String, String> clientEnv, Consumer<String> log) {
Map<String, String> requested = new TreeMap<>(clientEnv);
Map<String, String> actual = new TreeMap<>(System.getenv());
requested.put("PWD", Os.current().isCygwin() ? toCygwin(workingDir) : workingDir);
List<String> diffs = Stream.concat(requested.keySet().stream(), actual.keySet().stream())
.sorted()
.distinct()
.filter(s -> !s.startsWith("JAVA_MAIN_CLASS_"))
.filter(key -> !Objects.equals(requested.get(key), actual.get(key)))
.collect(Collectors.toList());
try {
for (String key : diffs) {
String vr = requested.get(key);
int rc = CLibrary.setenv(key, vr);
if (Os.current() == Os.WINDOWS ^ rc != 0) {
log.accept(String.format("Error setting environment value %s = %s", key, vr));
}
}
setEnv(requested);
chDir(workingDir);
} catch (Exception e) {
log.accept("Environment mismatch ! Could not set the environment (" + e + ")");
}
Map<String, String> nactual = new TreeMap<>(System.getenv());
diffs = Stream.concat(requested.keySet().stream(), actual.keySet().stream())
.sorted()
.distinct()
.filter(s -> !s.startsWith("JAVA_MAIN_CLASS_"))
.filter(key -> !Objects.equals(requested.get(key), nactual.get(key)))
.collect(Collectors.toList());
if (!diffs.isEmpty()) {
log.accept("A few environment mismatches have been detected between the client and the daemon.");
diffs.forEach(key -> {
String vr = requested.get(key);
String va = nactual.get(key);
log.accept(String.format(
" %s -> %s instead of %s",
key, va != null ? "'" + va + "'" : "<null>", vr != null ? "'" + vr + "'" : "<null>"));
});
log.accept("If the difference matters to you, stop the running daemons using mvnd --stop and");
log.accept("start a new daemon from the current environment by issuing any mvnd build command.");
}
}