mirror of
https://github.com/apache/maven-mvnd.git
synced 2026-01-13 07:04:14 +08:00
Calculate java home from java command (#716)
This commit is contained in:
@@ -44,6 +44,7 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
import org.mvndaemon.mvnd.common.Environment;
|
||||
import org.mvndaemon.mvnd.common.InterpolationHelper;
|
||||
import org.mvndaemon.mvnd.common.Os;
|
||||
import org.mvndaemon.mvnd.common.OsUtils;
|
||||
import org.mvndaemon.mvnd.common.SocketFamily;
|
||||
import org.mvndaemon.mvnd.common.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -137,6 +138,9 @@ public class DaemonParameters {
|
||||
.orLocalProperty(provider, globalPropertiesPath())
|
||||
.orSystemProperty()
|
||||
.orEnvironmentVariable()
|
||||
.or(new ValueSource(
|
||||
description -> description.append("java command"),
|
||||
this::javaHomeFromPath))
|
||||
.orFail()
|
||||
.asPath();
|
||||
try {
|
||||
@@ -146,6 +150,14 @@ public class DaemonParameters {
|
||||
}
|
||||
}
|
||||
|
||||
private String javaHomeFromPath() {
|
||||
final String jHome = OsUtils.findJavaHomeFromPath();
|
||||
if (null != jHome) {
|
||||
System.setProperty(Environment.JAVA_HOME.getProperty(), jHome);
|
||||
}
|
||||
return jHome;
|
||||
}
|
||||
|
||||
public Path userDir() {
|
||||
return value(Environment.USER_DIR)
|
||||
.orSystemProperty()
|
||||
|
||||
Reference in New Issue
Block a user