Conversation
Use existing Jansi and JLine metadata to select extended tokens while preserving explicit overrides and ASCII output for files, pipes, batch mode, and unknown capabilities. Keep Java 8 and Maven 3.6.3 compatibility. Fixes apache#997.
Explain why the exposed JLine terminal cannot identify the active logger destination when -l redirects output to a file. Document the conservative ASCII fallback and the supported explicit token overrides. Fixes apache#997.
wilx
force-pushed
the
issue-997-auto-tree-tokens
branch
from
September 19, 2026 23:47
e54a778 to
b624156
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a draft because the implementation seems way too involved for choosing tree branch characters. There should be a better way for Maven to give plugins information about its logging output capabilities, particularly the effective encoding and whether logging targets a console or a file. A supported Maven API for this would be preferable to making each plugin inspect logger implementations, stream identity and optional terminal-library versions.
Fixes #997 (MDEP-562).
Behavior
When
tokensis omitted, text trees use the existing extended box-drawing tokens if Maven is logging to an interactive terminal whose output encoding can represent all four branch characters. This supports UTF-8 and compatible legacy encodings such as CP437 and CP850. Detection reads Maven's existing JLine or Jansi metadata without installing a terminal, changing console settings or adding runtime dependencies.Explicit
-Dtokens=standard|extended|whitespacesettings take precedence and bypass detection. Automatic selection keeps ASCII foroutputFile,-l/--log-file, batch mode, redirected output, dumb terminals and unavailable or ambiguous metadata. Forced color does not override those checks. Other output formats are unchanged, and the Java 8 / Maven 3.6.3 minimum remains unchanged.Why this remains a draft
Maven 3.6.3's Jansi does not expose sufficient public metadata, so automatic selection remains ASCII there. Maven 4 also retains that fallback: both current 4.0.x and 4.1.x/master expose the JLine terminal but do not expose the active logging destination through a plugin-accessible API. A terminal can be present while the logger writes to a
-lfile. The logger has a package-privatelogSinkand a public setter, but no getter; the CLI selects the actual writer separately. The implementation avoids inspecting private fields.This limitation is documented in
ConsoleSupportand the goal documentation. Explicit extended tokens still work on those Maven versions. The draft is intended to support discussion of a Maven-level capability API and whether this amount of plugin-side detection is appropriate.Validation
mvn clean verify -Prun-its: all 103 integration builds passed.mvn verify -Prun-its '-Dinvoker.test=tree*': 465 unit tests, zero failures/errors, one existing skip; all nine tree integration builds passed.-l, forced color, separate stdout/stderr, and ASCII / CP437 / CP850 encodings. The final artifact passed all 20 final runtime checks.9a2aa9b036anda98d8fa111; the relevant logger implementation is identical. These branch tips were not runtime-tested.mvn spotless:apply spotless:checkandgit diff --checkpassed. The subsequent class Javadoc note changes no runtime behavior.Following this checklist to help us incorporate your
contribution quickly and easily:
Note that commits might be squashed by a maintainer on merge.
This may not always be possible but is a best-practice.
mvn verifyto make sure basic checks pass.A more thorough check will be performed on your pull request automatically.
mvn -Prun-its verify).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.