takari / maven-wrapper

The easiest way to integrate Maven into your project!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Maven `-Dstyle.color=always` option not working with the wrapper

sgautrin opened this issue · comments

Reproduction steps

  1. Add maven wrapper to a maven project with mvn -N io.takari:maven:0.7.6:wrapper -Dmaven=3.5.4 (reproduced also with latest maven version)
  2. execute any maven (with maven 3.5.3 or more recent) command with -Dstyle.color=always (added in maven 3.5.2, fixed in maven 3.5.3 with https://issues.apache.org/jira/browse/MNG-6296 ) and pipe it to less -R, e.g. mvn -Dstyle.color=always dependency:tree | less -R
  3. execute the same command using the wrapper instead

Expected

In both cases, we should have colourised output in less.

Observed

When using maven wrapper, output is not colourised in less, but it is as expected when using maven directly.

Note: previous workaround for forcing colour, using -Djansi.force=true instead, works with the wrapper as well as direct maven command.

Additional informations about environment where this has been observed

  1. Ubuntu 18.04.2 LTS WSL on Windows 10 1803 (build 17134.706)
  2. local maven version 3.6.0
  3. maven-wrapper versions 0.4.2 and 0.5.5 (updated and tested the latest version before creating the ticket)
  4. maven versions used by the wrapper: 3.5.4 and 3.6.1

This inconsistency is in Maven itself. The wrapper will not work around problems in Maven itself .. it just calls it.

This inconsistency is in Maven itself. The wrapper will not work around problems in Maven itself .. it just calls it.

Maybe my description was not clear enough or there's something that I fail to see, but how can it be an inconsistency in Maven itself when:

  • it works with maven
  • it does not work with maven wrapper

@mosabua Would you mind explaining us, why this is a Maven bug?
I really would like to see this fixed. If it's a bug in maven itself, I would open a ticket in the maven issue tracker. But I also thought this would be an issue in the wrapper. If you have any information please let us know.

I've been investigating a similar issue trying to get Jenkins to have colorized output. From what I understand, this isn't a bug at all, but a limitation of the wrapper, which executes Maven without an attached console. The jansi library needs an attached console to detect if the console can even support color. Since Maven probably isn't being executed in a console that the jansi library can recognize (it's being executed in the wrapper's Java code), you can force it to output color anyway by specifying -Djansi.force=true. This is just a reasoned guess, though... I don't like using maven-wrapper and don't know a lot about how it works internally.