You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/08/25 12:27:29 UTC

(maven) 01/01: Fix #12730: quiet mode implies raw streams to avoid stdout decoration (#12810)

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch backport/12810-to-maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 6a00b31af78a92484bca1577fed791b95ea334f9
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Aug 25 14:26:55 2026 +0200

    Fix #12730: quiet mode implies raw streams to avoid stdout decoration (#12810)
    
    When -q/--quiet is used, plugin stdout (e.g. help:evaluate
    -DforceStdout) was still wrapped by LoggingOutputStream which adds
    the "[INFO] [stdout] " prefix. This broke scripting use cases like
    $(mvn -q help:evaluate -Dexpression=prop -DforceStdout) that rely
    on clean, undecorated output — a regression from Maven 3.
    
    The root cause: doConfigureWithTerminalWithRawStreamsDisabled() creates
    stdout/stderr loggers hardcoded to INFO level and wraps System.out
    with a LoggingOutputStream that prefixes every line. Even though -q
    sets the root logger to ERROR, the explicit INFO on the stdout logger
    overrides it.
    
    The fix treats -q the same as --raw-streams: when quiet mode is
    active, System.out/System.err are set to the original raw streams
    (via doConfigureWithTerminalWithRawStreamsEnabled), bypassing the
    LoggingOutputStream wrapper entirely. This restores Maven 3 behavior
    where -q produced clean stdout suitable for scripting.
    
    Co-authored-by: Claude Opus 4.6 <no...@anthropic.com>
---
 .../src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
index 5ef24ad725..35de79ff86 100644
--- a/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
+++ b/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java
@@ -370,7 +370,11 @@ protected final void doConfigureWithTerminal(C context, Terminal terminal) {
                 context.coloredOutput != null ? context.coloredOutput : !Terminal.TYPE_DUMB.equals(terminal.getType()));
 
         // handle rawStreams: some would like to act on true, some on false
-        if (context.options().rawStreams().orElse(false)) {
+        // quiet mode implies raw streams — plugins that write to System.out (e.g. help:evaluate
+        // -DforceStdout) must not be decorated with "[INFO] [stdout]" prefix, otherwise scripting
+        // use cases like $(mvn -q help:evaluate ...) break (see GH-12730)
+        if (context.options().rawStreams().orElse(false)
+                || context.options().quiet().orElse(false)) {
             doConfigureWithTerminalWithRawStreamsEnabled(context);
         } else {
             doConfigureWithTerminalWithRawStreamsDisabled(context);