mirror of
https://github.com/apache/maven-mvnd.git
synced 2025-10-14 22:25:33 +00:00
Support -l / --log-file option
This commit is contained in:
@@ -15,10 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package org.jboss.fuse.mvnd.daemon;
|
package org.jboss.fuse.mvnd.daemon;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -27,8 +29,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.apache.maven.cli.CLIReportingUtils;
|
import org.apache.maven.cli.CLIReportingUtils;
|
||||||
import org.jboss.fuse.mvnd.daemon.Message.BuildEvent;
|
import org.jboss.fuse.mvnd.daemon.Message.BuildEvent;
|
||||||
@@ -107,6 +107,17 @@ public class Client {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String logFile = null;
|
||||||
|
for (int i = 0; i < args.size() - 2; i++) {
|
||||||
|
String arg = args.get(i);
|
||||||
|
if ("-l".equals(arg) || "--log-file".equals(arg)) {
|
||||||
|
logFile = args.get(i + 1);
|
||||||
|
args.remove(i);
|
||||||
|
args.remove(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setDefaultArgs(args);
|
setDefaultArgs(args);
|
||||||
|
|
||||||
DaemonConnector connector = new DaemonConnector(registry, Client::startDaemon, new MessageSerializer());
|
DaemonConnector connector = new DaemonConnector(registry, Client::startDaemon, new MessageSerializer());
|
||||||
@@ -156,11 +167,21 @@ public class Client {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
display.update(Collections.emptyList(), 0);
|
display.update(Collections.emptyList(), 0);
|
||||||
|
terminal.flush();
|
||||||
|
|
||||||
LOGGER.debug("Done receiving, printing log");
|
LOGGER.debug("Done receiving, printing log");
|
||||||
|
|
||||||
log.forEach(terminal.writer()::println);
|
if (logFile != null) {
|
||||||
terminal.flush();
|
try (BufferedWriter bw = Files.newBufferedWriter(Paths.get(logFile))) {
|
||||||
|
for (String l : log) {
|
||||||
|
bw.write(l);
|
||||||
|
bw.newLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.forEach(terminal.writer()::println);
|
||||||
|
terminal.flush();
|
||||||
|
}
|
||||||
|
|
||||||
LOGGER.debug("Done !");
|
LOGGER.debug("Done !");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user