Skip to content

Fix ANSI colors not disabled when piped on JDK 25+#11927

Open
utafrali wants to merge 1 commit intoapache:masterfrom
utafrali:fix/issue-11885-ansi-colors-jdk25-pipe
Open

Fix ANSI colors not disabled when piped on JDK 25+#11927
utafrali wants to merge 1 commit intoapache:masterfrom
utafrali:fix/issue-11885-ansi-colors-jdk25-pipe

Conversation

@utafrali
Copy link
Copy Markdown

On JDK 22+, System.console() returns a non-null Console even when stdout is redirected to a pipe or file. This caused Maven to select the color message scheme when output was piped.

Uses Console.isTerminal() (JDK 22+) via reflection to correctly detect piped output. On JDK < 22, falls back to the previous System.console() != null check.

Applied to both Maven 4 (LookupInvoker) and Maven 3 compat (MavenCli) code paths.

Closes #11885

On JDK 22+, System.console() returns non-null even when stdout is
redirected. Use Console.isTerminal() via reflection to correctly
detect piped output, falling back to the previous behavior on older
JDK versions.

Applied to both Maven 4 (LookupInvoker) and Maven 3 compat
(MavenCli) code paths.

Closes apache#11885
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ANSI colors are not disabled in case of redirect to pipe or file on JDK25+

1 participant