apache / maven-mvnd

Apache Maven Daemon
https://maven.apache.org/
Apache License 2.0
2.91k stars 208 forks source link

Interactive progress should go to stderr, not stdout #355

Open electrum opened 3 years ago

electrum commented 3 years ago

I need to get a list of dependencies for my project:

mvnd dependency:tree > out

This ran super fast, because mvnd is awesome, but it didn't show me the progress while running, and worse, the progress with all of the terminal escape codes was included in the output file from stdout. Also, the log output in the file was colored.

The behavior I expect is for mvnd to use stderr for progress, but only if stderr is a TTY, and that the log output to stdout is only colored if stdout is a TTY. This would match the behavior of the normal mvn command, except it would be fast and show the nice interactive progress:

mvn dependency:tree > out
gnodet commented 3 years ago

While I tend to agree, there is currently a limitation in JLine which does not support setting up a terminal with stdin/stderr instead of stdin/stdout, so this will require a new JLine feature / release.

For the ansi sequences, they could be stripped out. Note that the -l command line option should also be handled accordingly.

ppalaga commented 3 years ago

Standard Maven's -B could help to get rid of the ansi sequences.

gnodet commented 3 years ago

As a workaround, the desired behavior (progress + file output) can be achieved using the standard maven option

mvnd dependency:tree -l out

though the output in the out file still contains ansi sequences, but I'll fix this issue.