[ 
https://issues.apache.org/jira/browse/MNG-8535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17923118#comment-17923118
 ] 

Tamas Cservenak commented on MNG-8535:
--------------------------------------

Thanks, yes, "dumb" terminal can be only system terminal...
[~gnodet] WDYT? Should be have similar change for dumb terminal as we did with 
AnsiConsole (obey terminal not FS handles 
https://github.com/jline/jline3/commit/f869217bc933cf9bb93484f9492e9350e63b0726)
 or should we revive the PR similar to I had dropped 
(https://github.com/apache/maven/pull/2057) where one of the many (now split to 
separate PRs and merged) goals was to use "system" vs "non-system" terminal, 
depending on redirections...?

> 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
>            Assignee: Tamas Cservenak
>            Priority: Major
>             Fix For: 4.0.0-rc-3
>
>
> 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)

Reply via email to