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

cstamas pushed a commit to branch maven-3.10.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-3.10.x by this push:
     new 3363ebb74e Enable ANSI colors on Windows 11 terminals without 
WT_SESSION (fixes #14018) (#14039)
3363ebb74e is described below

commit 3363ebb74e3e37fcda036174a72a35e14c625485
Author: Tamas Cservenak <[email protected]>
AuthorDate: Wed Nov 18 18:50:22 2026 +0100

    Enable ANSI colors on Windows 11 terminals without WT_SESSION (fixes 
#14018) (#14039)
    
    Fixes #14018
    
    Since JLine was removed in 3.10.1, Maven turns colors on for a Windows 
console only when an environment variable shows the terminal handles ANSI 
escapes (WT_SESSION, ConEmuANSI, ANSICON, TERM_PROGRAM=vscode or TERM). A shell 
that Windows hands over to Windows Terminal, for example one launched by GitHub 
Desktop, does not get WT_SESSION, so colors were off even though the terminal 
renders them.
    
    Windows 11 uses Windows Terminal as the default terminal, and the legacy 
console host is opt-in there, so trust an interactive console on Windows 11 
too. Other Windows versions keep the environment variable checks, as the legacy 
console host does not process escapes unless the program enables it. Windows 11 
users who made the legacy console their default again can use --color=never.
---
 .../src/main/java/org/apache/maven/jline/MessageUtils.java     | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java 
b/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java
index 440a61f80c..3bfe92ddca 100644
--- a/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java
+++ b/maven-jline/src/main/java/org/apache/maven/jline/MessageUtils.java
@@ -145,10 +145,16 @@ static boolean detectAnsiTerminal() {
         } catch (ReflectiveOperationException e) {
             // Java < 22: a non-null console already means a terminal
         }
-        if (System.getProperty("os.name", "").startsWith("Windows")) {
+        String osName = System.getProperty("os.name", "");
+        if (osName.startsWith("Windows")) {
             // ponytail: no native call to switch on VT processing, so trust 
only consoles known to do ANSI already
             // (Windows Terminal, ConEmu/Cmder, ANSICON, VS Code, mintty & 
co); legacy conhost users use --color=always
-            return System.getenv("WT_SESSION") != null
+            // Windows 11 defaults to Windows Terminal, which may not set 
WT_SESSION when it gets a console via
+            // default-terminal handoff (e.g. shells launched by GitHub 
Desktop); conhost there is opt-in (#14018)
+            // shortcut: Win11 with conhost as default terminal shows raw 
escapes, use --color=never; needs a JDK
+            // that reports "Windows 11" (older ones say "Windows 10" and keep 
the env checks)
+            return osName.startsWith("Windows 11")
+                    || System.getenv("WT_SESSION") != null
                     || "ON".equals(System.getenv("ConEmuANSI"))
                     || System.getenv("ANSICON") != null
                     || "vscode".equals(System.getenv("TERM_PROGRAM"))

Reply via email to