gnodet commented on code in PR #2082:
URL: https://github.com/apache/maven/pull/2082#discussion_r1939322955


##########
impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java:
##########
@@ -305,16 +307,29 @@ protected BuildEventListener 
doDetermineBuildEventListener(C context) {
     }
 
     protected void createTerminal(C context) {
+        boolean stdStreamsRedirected = System.console() == null
+                || context.invokerRequest.in().isPresent()
+                || context.invokerRequest.out().isPresent()
+                || context.invokerRequest.err().isPresent();
+        context.invokerRequest.err().ifPresent(err -> {
+            if (err instanceof PrintStream errPs) {
+                System.setErr(errPs);
+            } else {
+                System.setErr(new PrintStream(err, true));
+            }
+        });
         if (context.terminal == null) {
             MessageUtils.systemInstall(
                     builder -> {
-                        builder.streams(
-                                context.invokerRequest.in().orElse(null),
-                                context.invokerRequest.out().orElse(null));
-                        
builder.systemOutput(TerminalBuilder.SystemOutput.ForcedSysOut);
-                        // The exec builder suffers from 
https://github.com/jline/jline3/issues/1098
-                        // We could re-enable it when fixed to provide support 
for non-standard architectures,
-                        // for which JLine does not provide any native library.
+                        if (stdStreamsRedirected) {
+                            builder.system(false);

Review Comment:
   `system(false)` and `system(true)` are not really needed, this is implicit 
with the fact that there are streams set.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to