wilx opened a new pull request, #1698: URL: https://github.com/apache/maven-dependency-plugin/pull/1698
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 `tokens` is 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|whitespace` settings take precedence and bypass detection. Automatic selection keeps ASCII for `outputFile`, `-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 `-l` file. The [logger](https://github.com/apache/maven/blob/a98d8fa111f76d2486a06bb6e263f6c1b822dfcc/impl/maven-logging/src/main/java/org/apache/maven/slf4j/MavenSimpleLogger.java#L42-L48) has a package-private `logSink` and a public setter, but no getter; the CLI [selects the actual writer separately](https://github.com/apache/maven/blob/a98d8fa111f76d2486a06bb6e263f6c1b822dfcc/impl/maven-cli/src/main/java/org/apache/maven/cling/invoker/LookupInvoker.java#L422-L446). The implementation avoids inspecting private fields. This limitation is documented in `ConsoleSupport` and 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 - Regression tests were written and observed failing before the corresponding implementation changes. - `mvn clean verify -Prun-its`: all 103 integration builds passed. - After the final runtime changes, `mvn verify -Prun-its '-Dinvoker.test=tree*'`: 465 unit tests, zero failures/errors, one existing skip; all nine tree integration builds passed. - Linux pseudo-terminal and redirected-output checks covered Maven 3.6.3 / Java 8, Maven 3.8.8 / Java 8, Maven 3.9.16 / Java 17 and 21, Maven 3.10.0-rc-1 / Java 21, and Maven 4.0.0-rc-6 / Java 21. Checks included explicit styles, batch mode, `-l`, forced color, separate stdout/stderr, and ASCII / CP437 / CP850 encodings. The final artifact passed all 20 final runtime checks. - Maven 4.0.x and 4.1.x/master were additionally inspected at `9a2aa9b036` and `a98d8fa111`; the relevant logger implementation is identical. These branch tips were not runtime-tested. - `mvn spotless:apply spotless:check` and `git diff --check` passed. The subsequent class Javadoc note changes no runtime behavior. - Native Windows and macOS console behavior has not been exercised. Following this checklist to help us incorporate your contribution quickly and easily: - [x] Your pull request should address just one issue, without pulling in other changes. - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. - [x] Each commit in the pull request should have a meaningful subject line and body. Note that commits might be squashed by a maintainer on merge. - [x] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible but is a best-practice. - [x] Run `mvn verify` to make sure basic checks pass. A more thorough check will be performed on your pull request automatically. - [x] You have run the integration tests successfully (`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](https://www.apache.org/licenses/icla.pdf) 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](http://www.apache.org/licenses/LICENSE-2.0) you have to acknowledge this by using the following check-box. - [x] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
