Stefan Oehme created MNG-8535:
---------------------------------
Summary: Embedded launcher can't capture Maven 4 output
Key: MNG-8535
URL: https://issues.apache.org/jira/browse/MNG-8535
Project: Maven
Issue Type: Bug
Components: Embedding
Affects Versions: 4.0.0-rc-3
Reporter: Stefan Oehme
We have a lot of tests capturing and validating the output of Maven builds and
use an embedded launcher by default to make our tests fast. With Maven 4 and
CliNG, our embedder can no longer capture Maven's output. At first I thought
there was something wrong with our embedder, but I can reproduce this with the
EmbeddedMavenExecutor provided by the Maven team as well:
{code:java}
public static void main(String[] args) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
new EmbeddedMavenExecutor(false).execute(ExecutorRequest
.mavenBuilder(Paths.get("/path/to/apache-maven-4.0.0-rc-3-SNAPSHOT"))
.cwd(Paths.get("/path/to/simple-project"))
.argument("package")
.stdoutConsumer(out)
.build()
);
System.out.println("Output was: " + out);
} {code}
The above program should capture Maven's output, but actually the output is
dumped directly to the console and the `out` variable remains empty.
This puzzled me, because the embedded launcher [does replace System.out and
System.err|https://github.com/apache/maven/blob/master/impl/maven-executor/src/main/java/org/apache/maven/cling/executor/embedded/EmbeddedMavenExecutor.java#L148],
so it looks like it should work. After some digging I found out that this is
because of JLine. It doesn't use System.out or System.err, [but instead writes
directly to the underlying filedescriptors
|https://github.com/jline/jline3/blob/4504b461ba719749d9d9276be11df26d4524914a/terminal/src/main/java/org/jline/terminal/impl/DumbTerminalProvider.java#L50]
Please provide a way to capture Maven 4's output with the embedded launcher,
like we used to be able with Maven 3.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)