How to adjust colors in maven 3.5 console output

Maven 3.5.0 injects coloring into the console output.

This is a cool feature, but I don’t like some of the default choices, for example the intense blue INFO looks too distracting.

Is there any way to adjust the colors?

+5
source share
1 answer

It turns out that this is possible.

Maven uses several styles to format its output:

enum Style { DEBUG( "bold,cyan" ), INFO( "bold,blue" ), WARNING( "bold,yellow" ), ERROR( "bold,red" ), SUCCESS( "bold,green" ), FAILURE( "bold,red" ), STRONG( "bold" ), MOJO( "green" ), PROJECT( "cyan" ); ... } 

You can override the default color of the style with the system property style.style_name . For example, to change the default INFO style from blue to dark gray, you go through

-Dstyle.info=bold,black

for maven. It can also be specified with the environment variable MAVEN_OPTS , so as not to type it with every maven call.

If you don’t know which style is used in a specific part of the output, you can map it by default.

The colors that can be used in the style are determined by jansi :

 public enum Color { BLACK(0, "BLACK"), RED(1, "RED"), GREEN(2, "GREEN"), YELLOW(3, "YELLOW"), BLUE(4, "BLUE"), MAGENTA(5, "MAGENTA"), CYAN(6, "CYAN"), WHITE(7, "WHITE"), DEFAULT(9, "DEFAULT"); } 

It seems that you can prefix the color with bg to indicate the background color, and to add it intensively you add the bold modifier, for example: bold,white,bgcyan - intense white color on a blue background.

+6
source

Source: https://habr.com/ru/post/1266759/


All Articles