[MDEP-839] dependency:list should output a plain list when used with a file
Christoph Läubrich opened MDEP-839 and commented
There is a parameter to redirect the output to a file:
https://maven.apache.org/plugins/maven-dependency-plugin/list-mojo.html#outputFile
This currently has some issues I would not expect when redirecting such content to a file:
- First line in the file is empty
- Second line says 'The following files have been resolved:'
- next lines are indented
- ANSI Escape Characters are emmited e.g. [36m -- module maven.core[0;1;33m (auto)[m
What I would expect:
Each line just contains the raw resolved dependency e.g. "org.apache.maven:maven-core:jar:3.8.6:provided" and no more content is printed out, especially no ANSI Escapes
Remote Links:
Elliotte Rusty Harold commented
Which command are you running specifically? Different commands run along different code paths and produce different output.
Elliotte Rusty Harold commented
Note that depending on what's in the tree there can be other messages here as well. Specifically:
"The following files were skipped:" and "The following files have NOT been resolved:"
This goal does not seem to be meant to produce a machine readable list of dependencies.
Christoph Läubrich commented
Yes the documentation says:
If specified, this parameter causes the dependencies to be written to the path specified instead of the console.
So I would have expected it only prints the dependencies itself in a somewhat machine readable format, at least not something with some strange color codes or arbitrary messages.
Elliotte Rusty Harold commented
I'm unable to reproduce the escape codes in the file:
mvn org.apache.maven.plugins:maven-dependency-plugin:3.8.1:list -DoutputFile=temp.txt
Anyone have a test case that shows this?
Elliotte Rusty Harold commented
I've fixed as much of this as I could reproduce and that we want to fix. I could not reproduce the issue with ANSI escape characters. If anyone can reproduce that in a test case, we can reopen.
Elliotte Rusty Harold commented
I've fixed as much of this as I could reproduce and that we want to fix. I could not reproduce the issue with ANSI escape characters. If anyone can reproduce that in a test case, we can reopen.
@elharo issue is still occurring with 3.9.0; see https://github.com/tiffmaelite/maven-dependency-plugin-ansi-codes-bug
This might help, but what we really need is a PR against head.
I cannot repro that on my MacBook. There might be other issues in play. I do not see the same output you do, even after considering escape characters. In particular I don't see the module lines.
OK, now I'm getting somewhere. The bug shows up with Java 17 but but Java 8. Not sure why the JDK makes a difference here, but it does
Problem seems likely related to these lines in ResolveDependenciesMojo:
/* if (outputFile != null) {
MessageUtils.setColorEnabled(false);
} else {
MessageUtils.setColorEnabled(true);
} */
what I don't understand is why mdep-839-list isn't picking up this issue
For unclear reasons the integration tests don't use JAnsi. Think I need to add it to the test classpath