Attempt at moving mvn as first class citizen in mvnd distribution, #392 (#769)

This commit is contained in:
Guillaume Nodet
2023-01-24 10:50:40 +01:00
committed by GitHub
parent b2bd0aaae5
commit 4f90d558b2
18 changed files with 88 additions and 103 deletions

View File

@@ -339,7 +339,7 @@ public class DaemonConnector {
final Path mvndHome = parameters.mvndHome();
final Path workingDir = parameters.userDir();
String command = "";
try (DirectoryStream<Path> jarPaths = Files.newDirectoryStream(mvndHome.resolve("mvn/lib/ext"))) {
try (DirectoryStream<Path> jarPaths = Files.newDirectoryStream(mvndHome.resolve("lib"))) {
List<String> args = new ArrayList<>();
// executable
final String java = Os.current().isUnixLike() ? "bin/java" : "bin\\java.exe";
@@ -358,10 +358,10 @@ public class DaemonConnector {
}
}
if (mvndCommonPath == null) {
throw new IllegalStateException("Could not find mvnd-common jar in mvn/lib/ext/");
throw new IllegalStateException("Could not find mvnd-common jar in lib/");
}
if (mvndAgentPath == null) {
throw new IllegalStateException("Could not find mvnd-agent jar in mvn/lib/ext/");
throw new IllegalStateException("Could not find mvnd-agent jar in lib/");
}
args.add("-classpath");
args.add(mvndCommonPath + File.pathSeparator + mvndAgentPath);
@@ -419,8 +419,8 @@ public class DaemonConnector {
}
Environment.MVND_HOME.addSystemProperty(args, mvndHome.toString());
args.add("-Dmaven.home=" + mvndHome.resolve("mvn"));
args.add("-Dmaven.conf=" + mvndHome.resolve("mvn/conf"));
args.add("-Dmaven.home=" + mvndHome);
args.add("-Dmaven.conf=" + mvndHome.resolve("conf"));
Environment.MVND_JAVA_HOME.addSystemProperty(
args, parameters.javaHome().toString());

View File

@@ -120,10 +120,10 @@ public class DaemonParameters {
private String mvndHomeFromExecutable() {
Optional<String> cmd = ProcessHandle.current().info().command();
if (Environment.isNative() && cmd.isPresent()) {
final Path mvndH = Paths.get(cmd.get()).getParent().getParent();
final Path mvndH = Paths.get(cmd.get()).getParent();
if (mvndH != null) {
final Path mvndDaemonLib = mvndH.resolve("mvn/lib/ext/mvnd-daemon-"
+ BuildProperties.getInstance().getVersion() + ".jar");
final Path mvndDaemonLib = mvndH.resolve(
"lib/mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar");
if (Files.exists(mvndDaemonLib)) {
return mvndH.toString();
}
@@ -238,7 +238,8 @@ public class DaemonParameters {
public Path logbackConfigurationPath() {
return property(Environment.MVND_LOGBACK)
.orDefault(() -> mvndHome().resolve("conf/logback.xml").toString())
.orDefault(() ->
mvndHome().resolve("conf/logging/logback-mvnd.xml").toString())
.orFail()
.asPath();
}