in client/src/main/java/org/mvndaemon/mvnd/client/DaemonParameters.java [121:153]
private String mvndHomeFromExecutable() {
Optional<String> cmd = ProcessHandle.current().info().command();
if (Environment.isNative() && cmd.isPresent()) {
String cmdStr = cmd.get();
// When running on alpine, musl uses a dynamic loader
// which is used as the main exec and the full path to the
// executable is the argument following "--"
if (cmdStr.startsWith("/lib/ld-musl-")) {
Optional<String[]> args = ProcessHandle.current().info().arguments();
if (args.isPresent()) {
boolean nextIsArg0 = false;
for (String arg : args.get()) {
if (nextIsArg0) {
cmdStr = arg;
break;
} else {
nextIsArg0 = "--".equals(arg);
}
}
}
}
Path mvndH = Paths.get(cmdStr).getParent().getParent();
if (mvndH != null) {
Path mvndDaemon =
Paths.get("mvnd-daemon-" + BuildProperties.getInstance().getVersion() + ".jar");
if (Files.exists(
mvndH.resolve("mvn").resolve("lib").resolve("mvnd").resolve(mvndDaemon))) {
return mvndH.toString();
}
}
}
return null;
}