I am using maven cli to run maven command from Java. Since the below method accepts only PrintStream
object as input, how do I write maven build log to Logger
instead of System.out
. I am not trying to put all of system.out and system.err onto logger. All I need is to pass the argument to MavenCli domain() method so that I can redirect the method(build) logs to Logger.
MavenCli cli = new MavenCli();
Integer result = cli.doMain(new String[]{"clean","package","-Dmaven.test.skip=true"},
pathToPom,
System.out, System.out);
Fixed the issue. Build log is being written to temp text file. MavenCli cli = new MavenCli(); String dir = AppProperties.getEnvProperty("queue"); PrintStream stdout = new PrintStream( new File("temp.txt") ); result = cli.doMain(new String[]{"clean","package","-Dmaven.test.skip=true"}, pathToPom, stdout, stdout);