mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-09-28 08:47:29 +00:00
ProjectBuildLogAppender not found when starting the daemon #165
This commit is contained in:
@@ -16,12 +16,10 @@
|
||||
package org.jboss.fuse.mvnd.client;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
import java.nio.channels.SocketChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -33,9 +31,7 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
import org.jboss.fuse.mvnd.common.BuildProperties;
|
||||
import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec;
|
||||
import org.jboss.fuse.mvnd.common.DaemonCompatibilitySpec.Result;
|
||||
@@ -252,11 +248,8 @@ public class DaemonConnector {
|
||||
final Path workingDir = layout.userDir();
|
||||
String command = "";
|
||||
try {
|
||||
String classpath = findJars(
|
||||
mavenHome,
|
||||
p -> p.getFileName().toString().equals("mvnd-common-" + buildProperties.getVersion() + ".jar"),
|
||||
p -> p.getFileName().toString().startsWith("slf4j-api-"),
|
||||
p -> p.getFileName().toString().startsWith("logback-"));
|
||||
final String classpath = mavenHome.resolve("mvn/lib/ext/mvnd-common-" + buildProperties.getVersion() + ".jar")
|
||||
.toString();
|
||||
final String java = Os.current().isUnixLike() ? "bin/java" : "bin\\java.exe";
|
||||
List<String> args = new ArrayList<>();
|
||||
args.add(layout.javaHome().resolve(java).toString());
|
||||
@@ -269,6 +262,9 @@ public class DaemonConnector {
|
||||
args.add("-Dmvnd.java.home=" + layout.javaHome().toString());
|
||||
args.add("-Dlogback.configurationFile=" + layout.getLogbackConfigurationPath());
|
||||
args.add("-Ddaemon.uid=" + uid);
|
||||
if (Boolean.getBoolean(Environment.DEBUG_ENVIRONMENT_PROP)) {
|
||||
args.add("-D" + Environment.DEBUG_ENVIRONMENT_PROP + "=true");
|
||||
}
|
||||
args.add("-Xmx4g");
|
||||
args.add(Environment.DAEMON_IDLE_TIMEOUT_MS.asCommandLineProperty(Integer.toString(layout.getIdleTimeoutMs())));
|
||||
args.add(Environment.DAEMON_KEEP_ALIVE_MS.asCommandLineProperty(Integer.toString(layout.getKeepAliveMs())));
|
||||
@@ -292,18 +288,6 @@ public class DaemonConnector {
|
||||
}
|
||||
}
|
||||
|
||||
private String findJars(Path mavenHome, Predicate<Path>... filters) {
|
||||
final Path libExtDir = mavenHome.resolve("mvn/lib/ext");
|
||||
try (Stream<Path> jars = Files.list(libExtDir)) {
|
||||
return jars
|
||||
.filter(Stream.of(filters).reduce((previous, current) -> previous.or(current)).get())
|
||||
.map(Path::toString)
|
||||
.collect(Collectors.joining(File.pathSeparator));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not list " + libExtDir);
|
||||
}
|
||||
}
|
||||
|
||||
private DaemonClientConnection connectToDaemonWithId(String daemon, boolean newDaemon)
|
||||
throws DaemonException.ConnectException {
|
||||
// Look for 'our' daemon among the busy daemons - a daemon will start in busy state so that nobody else will
|
||||
|
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import org.slf4j.Logger;
|
||||
@@ -54,7 +55,33 @@ public enum Environment {
|
||||
|
||||
public static final int DEFAULT_MIN_THREADS = 1;
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Environment.class);
|
||||
private static final Consumer<String> LOG;
|
||||
private static final boolean DEBUG_ENABLED;
|
||||
public static final String DEBUG_ENVIRONMENT_PROP = "mvnd.environment.debug";
|
||||
|
||||
static {
|
||||
Consumer<String> log = null;
|
||||
boolean debugEnabled = false;
|
||||
try {
|
||||
Logger logger = LoggerFactory.getLogger(Environment.class);
|
||||
log = logger::debug;
|
||||
debugEnabled = logger.isDebugEnabled();
|
||||
} catch (java.lang.NoClassDefFoundError e) {
|
||||
if (e.getMessage().contains("org/slf4j/LoggerFactory")) {
|
||||
/* This is when we are in the daemon's boot class path where slf4j is not available */
|
||||
if (Boolean.getBoolean(DEBUG_ENVIRONMENT_PROP)) {
|
||||
log = s -> System.out.println("mvnd.environment: " + s);
|
||||
debugEnabled = true;
|
||||
}
|
||||
} else {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
LOG = log != null ? log : s -> {
|
||||
};
|
||||
DEBUG_ENABLED = debugEnabled;
|
||||
}
|
||||
|
||||
static Properties properties = System.getProperties();
|
||||
static Map<String, String> env = System.getenv();
|
||||
|
||||
@@ -276,7 +303,7 @@ public enum Environment {
|
||||
}
|
||||
}
|
||||
final String result = valueSource.valueSupplier.get();
|
||||
if (result != null && LOG.isDebugEnabled()) {
|
||||
if (result != null && DEBUG_ENABLED) {
|
||||
StringBuilder sb = new StringBuilder("Loaded environment value for key [")
|
||||
.append(envKey.name())
|
||||
.append("] from ");
|
||||
@@ -284,7 +311,7 @@ public enum Environment {
|
||||
sb.append(": [")
|
||||
.append(result)
|
||||
.append(']');
|
||||
LOG.debug(sb.toString());
|
||||
LOG.accept(sb.toString());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user