in daemon-m39/src/main/java/org/apache/maven/cli/DaemonMavenCli.java [824:873]
private void logSummary(
ExceptionSummary summary, Map<String, String> references, String indent, boolean showErrors) {
String msg = summary.getMessage();
if (!summary.getReference().isEmpty()) {
String referenceKey =
references.computeIfAbsent(summary.getReference(), k -> "[Help " + (references.size() + 1) + "]");
if (msg.indexOf('\n') < 0) {
msg += " -> " + buffer().strong(referenceKey);
} else {
msg += "\n-> " + buffer().strong(referenceKey);
}
}
String[] lines = msg.split("(\r\n)|(\r)|(\n)");
String currentColor = "";
for (int i = 0; i < lines.length; i++) {
// add eventual current color inherited from previous line
String line = currentColor + lines[i];
// look for last ANSI escape sequence to check if nextColor
Matcher matcher = LAST_ANSI_SEQUENCE.matcher(line);
String nextColor = "";
if (matcher.find()) {
nextColor = matcher.group(1);
if (ANSI_RESET.equals(nextColor)) {
// last ANSI escape code is reset: no next color
nextColor = "";
}
}
// effective line, with indent and reset if end is colored
line = indent + line + ("".equals(nextColor) ? "" : ANSI_RESET);
if ((i == lines.length - 1) && (showErrors || (summary.getException() instanceof InternalErrorException))) {
slf4jLogger.error(line, summary.getException());
} else {
slf4jLogger.error(line);
}
currentColor = nextColor;
}
indent += " ";
for (ExceptionSummary child : summary.getChildren()) {
logSummary(child, references, indent, showErrors);
}
}