mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-26 05:58:27 +00:00
Fix #53 Using MAVEN_HOME may clash with other tools
This commit is contained in:
@@ -247,7 +247,7 @@ public class DaemonConnector {
|
||||
if (Environment.DAEMON_DEBUG.systemProperty().orDefault(() -> "false").asBoolean()) {
|
||||
args.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=8000");
|
||||
}
|
||||
args.add("-Dmaven.home=\"" + mavenHome + "\"");
|
||||
args.add("-Dmvnd.home=\"" + mavenHome + "\"");
|
||||
args.add("-Dlogback.configurationFile=\"" + layout.getLogbackConfigurationPath() + "\"");
|
||||
args.add("-Ddaemon.uid=" + uid);
|
||||
args.add("-Xmx4g");
|
||||
|
@@ -77,7 +77,7 @@ public class DefaultClient implements Client {
|
||||
.orDefault(() -> "https://github.com/mvndaemon/mvnd/releases/download/" + version + "/mvnd-dist.zip")
|
||||
.asString();
|
||||
final URI zipUri = URI.create(rawZipUri);
|
||||
final Path mvndHome = Environment.MAVEN_HOME
|
||||
final Path mvndHome = Environment.MVND_HOME
|
||||
.commandLineProperty(() -> commandLineProperties)
|
||||
.orEnvironmentVariable()
|
||||
.orSystemProperty()
|
||||
|
@@ -32,7 +32,7 @@ import java.util.function.Supplier;
|
||||
public enum Environment {
|
||||
LOGBACK_CONFIGURATION_FILE("logback.configurationFile", null),
|
||||
JAVA_HOME("java.home", "JAVA_HOME"),
|
||||
MAVEN_HOME("maven.home", "MAVEN_HOME"),
|
||||
MVND_HOME("mvnd.home", "MVND_HOME"),
|
||||
MAVEN_REPO_LOCAL("maven.repo.local", null),
|
||||
MAVEN_MULTIMODULE_PROJECT_DIRECTORY("maven.multiModuleProjectDirectory", null),
|
||||
MVND_PROPERTIES_PATH("mvnd.properties.path", "MVND_PROPERTIES_PATH"),
|
||||
@@ -108,7 +108,7 @@ public enum Environment {
|
||||
}
|
||||
|
||||
public static EnvValue findBasicMavenHome() {
|
||||
return MAVEN_HOME
|
||||
return MVND_HOME
|
||||
.environmentVariable()
|
||||
.orSystemProperty();
|
||||
}
|
||||
|
@@ -26,7 +26,7 @@ public class ServerMain {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
final String uidStr = Environment.DAEMON_UID.systemProperty().orFail().asString();
|
||||
final Path mavenHome = Environment.MAVEN_HOME.systemProperty().orFail().asPath();
|
||||
final Path mavenHome = Environment.MVND_HOME.systemProperty().orFail().asPath();
|
||||
URL[] classpath = Stream.concat(
|
||||
Stream.concat(Files.list(mavenHome.resolve("lib/ext")),
|
||||
Files.list(mavenHome.resolve("lib")))
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# An absolute path to your Maven Daemon installation
|
||||
maven.home = %s
|
||||
mvnd.home = %s
|
||||
|
||||
# java.home is optional if you have JAVA_HOME environment variable set
|
||||
%s
|
||||
|
@@ -27,16 +27,16 @@ public class EnvironmentTest {
|
||||
@Test
|
||||
void prop() {
|
||||
try (EnvironmentResource env = new EnvironmentResource()) {
|
||||
env.props("maven.home", "/maven/home/prop");
|
||||
Assertions.assertEquals("/maven/home/prop", Environment.MAVEN_HOME.systemProperty().asString());
|
||||
env.props("mvnd.home", "/maven/home/prop");
|
||||
Assertions.assertEquals("/maven/home/prop", Environment.MVND_HOME.systemProperty().asString());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void env() {
|
||||
try (EnvironmentResource env = new EnvironmentResource()) {
|
||||
env.env("MAVEN_HOME", "/maven/home/env");
|
||||
Assertions.assertEquals("/maven/home/env", Environment.MAVEN_HOME.environmentVariable().asString());
|
||||
env.env("MVND_HOME", "/maven/home/env");
|
||||
Assertions.assertEquals("/maven/home/env", Environment.MVND_HOME.environmentVariable().asString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,9 +44,9 @@ public class EnvironmentTest {
|
||||
void localProps() {
|
||||
try (EnvironmentResource env = new EnvironmentResource()) {
|
||||
final Properties localProps = new Properties();
|
||||
localProps.put("maven.home", "/maven/home/local");
|
||||
localProps.put("mvnd.home", "/maven/home/local");
|
||||
Assertions.assertEquals(Paths.get("/maven/home/local"),
|
||||
Environment.MAVEN_HOME
|
||||
Environment.MVND_HOME
|
||||
.environmentVariable()
|
||||
.orSystemProperty()
|
||||
.orLocalProperty(() -> localProps, Paths.get("/local/properties"))
|
||||
@@ -58,10 +58,10 @@ public class EnvironmentTest {
|
||||
@Test
|
||||
void envBeforeProp() {
|
||||
try (EnvironmentResource env = new EnvironmentResource()) {
|
||||
env.props("maven.home", "/maven/home/prop");
|
||||
env.env("MAVEN_HOME", "/maven/home/env");
|
||||
env.props("mvnd.home", "/maven/home/prop");
|
||||
env.env("MVND_HOME", "/maven/home/env");
|
||||
Assertions.assertEquals("/maven/home/env",
|
||||
Environment.MAVEN_HOME
|
||||
Environment.MVND_HOME
|
||||
.environmentVariable()
|
||||
.orSystemProperty()
|
||||
.asString());
|
||||
@@ -73,7 +73,7 @@ public class EnvironmentTest {
|
||||
try (EnvironmentResource env = new EnvironmentResource()) {
|
||||
try {
|
||||
Assertions.assertEquals("/maven/home/env",
|
||||
Environment.MAVEN_HOME
|
||||
Environment.MVND_HOME
|
||||
.environmentVariable()
|
||||
.orSystemProperty()
|
||||
.orFail()
|
||||
@@ -81,7 +81,7 @@ public class EnvironmentTest {
|
||||
Assertions.fail("IllegalStateException expected");
|
||||
} catch (IllegalStateException e) {
|
||||
Assertions.assertEquals(
|
||||
"Could not get value for Environment.MAVEN_HOME from any of the following sources: environment variable MAVEN_HOME, system property maven.home",
|
||||
"Could not get value for Environment.MVND_HOME from any of the following sources: environment variable MVND_HOME, system property mvnd.home",
|
||||
e.getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -194,7 +194,7 @@ exec "$JAVACMD" \
|
||||
$MAVEN_DEBUG_OPTS \
|
||||
-classpath "${DAEMON_JAR}" \
|
||||
"-Dlogback.configurationFile=${MVND_HOME}/conf/logging/logback.xml" \
|
||||
"-Dmaven.home=${MVND_HOME}" \
|
||||
"-Dmvnd.home=${MVND_HOME}" \
|
||||
"-Dlibrary.jansi.path=${MVND_HOME}/lib/jansi-native" \
|
||||
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
|
||||
${DAEMON_LAUNCHER} "$@"
|
||||
|
@@ -33,7 +33,7 @@
|
||||
</appender>
|
||||
|
||||
<appender name="DAEMON" class="ch.qos.logback.core.FileAppender">
|
||||
<file>${maven.home}/daemon/daemon-${daemon.uid}.log</file>
|
||||
<file>${mvnd.home}/daemon/daemon-${daemon.uid}.log</file>
|
||||
<encoder>
|
||||
<pattern>%d{HH:mm:ss.SSS} %.-1level %msg%n</pattern>
|
||||
</encoder>
|
||||
|
@@ -200,9 +200,10 @@ public class DaemonMavenCli {
|
||||
// Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative
|
||||
// Windows paths.
|
||||
//
|
||||
String mavenHome = System.getProperty("maven.home");
|
||||
String mavenHome = System.getProperty("mvnd.home");
|
||||
|
||||
if (mavenHome != null) {
|
||||
System.setProperty("mvnd.home", new File(mavenHome).getAbsolutePath());
|
||||
System.setProperty("maven.home", new File(mavenHome).getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class InstallDaemonNativeIT {
|
||||
Environment.MVND_DIST_URI.asCommandLineProperty(mvndDistUri),
|
||||
Environment.MVND_PROPERTIES_PATH.asCommandLineProperty(mvndPropertiesPath.toString()),
|
||||
Environment.JAVA_HOME.asCommandLineProperty(layout.javaHome().toString()),
|
||||
Environment.MAVEN_HOME.asCommandLineProperty(mavenHome.toString()))
|
||||
Environment.MVND_HOME.asCommandLineProperty(mavenHome.toString()))
|
||||
.assertSuccess();
|
||||
|
||||
Assertions.assertThat(mvndPropertiesPath).exists();
|
||||
|
@@ -69,8 +69,8 @@ public class NativeTestClient implements Client {
|
||||
.redirectErrorStream(true);
|
||||
|
||||
final Map<String, String> env = builder.environment();
|
||||
if (!Environment.MAVEN_HOME.hasCommandLineProperty(args)) {
|
||||
env.put("MAVEN_HOME", System.getProperty("mvnd.home"));
|
||||
if (!Environment.MVND_HOME.hasCommandLineProperty(args)) {
|
||||
env.put("MVND_HOME", System.getProperty("mvnd.home"));
|
||||
}
|
||||
if (!Environment.JAVA_HOME.hasCommandLineProperty(args)) {
|
||||
env.put("JAVA_HOME", System.getProperty("java.home"));
|
||||
|
Reference in New Issue
Block a user