diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
index 38986dd3..5660eee8 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DaemonConnector.java
@@ -372,6 +372,9 @@ public class DaemonConnector {
}
Environment.MVND_HOME.addCommandLineOption(args, mvndHome.toString());
+ args.add("-Dmaven.home=" + mvndHome.resolve("mvn"));
+ args.add("-Dmaven.conf=" + mvndHome.resolve("mvn/conf"));
+
Environment.MVND_JAVA_HOME.addCommandLineOption(args, parameters.javaHome().toString());
Environment.LOGBACK_CONFIGURATION_FILE
.addCommandLineOption(args, parameters.logbackConfigurationPath().toString());
diff --git a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
index 9f33215c..72fba870 100644
--- a/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
+++ b/client/src/main/java/org/mvndaemon/mvnd/client/DefaultClient.java
@@ -112,6 +112,8 @@ public class DefaultClient implements Client {
System.setProperty(Environment.MVND_NO_BUFERING.getProperty(), Boolean.toString(true));
}
+ System.setProperty(Environment.MVND_HOME.getProperty(), parameters.mvndHome().toString());
+
int exitCode = 0;
boolean noBuffering = batchMode || parameters.noBuffering();
try (TerminalOutput output = new TerminalOutput(noBuffering, parameters.rollingWindowSize(), logFile)) {
diff --git a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
index 20547e63..a2d3b001 100644
--- a/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
+++ b/common/src/main/java/org/mvndaemon/mvnd/common/Environment.java
@@ -79,7 +79,7 @@ public enum Environment {
* The daemon installation directory. The client normally sets this according to where its mvnd
* executable is located
*/
- MVND_HOME("mvnd.home", "MVND_HOME", null, OptionType.PATH, Flags.NONE),
+ MVND_HOME("mvnd.home", "MVND_HOME", null, OptionType.PATH, Flags.DISCRIMINATING),
/** The user home directory */
USER_HOME("user.home", null, null, OptionType.PATH, Flags.NONE),
/** The current working directory */
diff --git a/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java b/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
index b55ecc51..746f1df7 100644
--- a/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
+++ b/daemon/src/main/java/org/apache/maven/cli/DaemonMavenCli.java
@@ -260,17 +260,6 @@ public class DaemonMavenCli {
throw new ExitException(1);
}
System.setProperty("maven.multiModuleProjectDirectory", cliRequest.multiModuleProjectDirectory.toString());
-
- //
- // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative
- // Windows paths.
- //
- String mvndHome = System.getProperty("mvnd.home");
-
- if (mvndHome != null) {
- System.setProperty("mvnd.home", new File(mvndHome).getAbsolutePath());
- System.setProperty("maven.home", new File(mvndHome + "/mvn").getAbsolutePath());
- }
}
void cli(CliRequest cliRequest)
diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java
new file mode 100644
index 00000000..8a694c62
--- /dev/null
+++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfNativeIT.java
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2019-2022 the original author or authors.
+ *
+ * Licensed 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.mvndaemon.mvnd.it;
+
+import java.io.IOException;
+import javax.inject.Inject;
+import org.junit.jupiter.api.Test;
+import org.mvndaemon.mvnd.assertj.TestClientOutput;
+import org.mvndaemon.mvnd.client.Client;
+import org.mvndaemon.mvnd.client.DaemonParameters;
+import org.mvndaemon.mvnd.junit.MvndNativeTest;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@MvndNativeTest(projectDir = "src/test/projects/maven-conf")
+public class MavenConfNativeIT {
+
+ @Inject
+ Client client;
+
+ @Inject
+ DaemonParameters parameters;
+
+ @Test
+ void version() throws IOException, InterruptedException {
+ final TestClientOutput o = new TestClientOutput();
+ client.execute(o, "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate",
+ "-Dexpression=maven.conf", "-q", "-DforceStdout", "--raw-streams").assertSuccess();
+ String conf = parameters.mvndHome().resolve("mvn/conf").toString();
+ assertTrue(o.getMessages().stream()
+ .anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
+ }
+
+}
diff --git a/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfTest.java b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfTest.java
new file mode 100644
index 00000000..768ace5a
--- /dev/null
+++ b/integration-tests/src/test/java/org/mvndaemon/mvnd/it/MavenConfTest.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2019-2022 the original author or authors.
+ *
+ * Licensed 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.mvndaemon.mvnd.it;
+
+import java.io.IOException;
+import javax.inject.Inject;
+import org.junit.jupiter.api.Test;
+import org.mvndaemon.mvnd.assertj.TestClientOutput;
+import org.mvndaemon.mvnd.client.Client;
+import org.mvndaemon.mvnd.client.DaemonParameters;
+import org.mvndaemon.mvnd.junit.MvndTest;
+import org.mvndaemon.mvnd.junit.TestRegistry;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+@MvndTest(projectDir = "src/test/projects/maven-conf")
+public class MavenConfTest extends MavenConfNativeIT {
+
+ @Inject
+ Client client;
+
+ @Inject
+ DaemonParameters parameters;
+
+ @Inject
+ TestRegistry registry;
+
+ @Test
+ void version() throws IOException, InterruptedException {
+ final TestClientOutput o = new TestClientOutput();
+ client.execute(o, "org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate",
+ "-Dexpression=maven.conf", "-q", "-DforceStdout", "--raw-streams").assertSuccess();
+ String conf = parameters.mvndHome().resolve("mvn/conf").toString();
+ assertTrue(o.getMessages().stream()
+ .anyMatch(m -> m.toString().contains(conf)), "Output should contain " + conf);
+ }
+
+}
diff --git a/integration-tests/src/test/projects/maven-conf/pom.xml b/integration-tests/src/test/projects/maven-conf/pom.xml
new file mode 100644
index 00000000..2aa36cde
--- /dev/null
+++ b/integration-tests/src/test/projects/maven-conf/pom.xml
@@ -0,0 +1,27 @@
+
+
+ 4.0.0
+
+ org.mvndaemon.mvnd.test.maven-conf
+ maven-conf
+ 0.0.1-SNAPSHOT
+ pom
+
+
\ No newline at end of file