Ilya
Ilya

Reputation: 23125

How to customize colors in maven 3.5 console output

Maven 3.5.0 introduces coloring in console output.

It's a cool feature, however I don't like some default color choices, for example intensive blue INFO looks too distracting.

Is it possible to customize colors somehow?

Upvotes: 11

Views: 10074

Answers (2)

Ilya
Ilya

Reputation: 23125

Turns out it 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 a style with the system property style.style_name. For example to change the style of INFO from default blue to dark gray you pass

-Dstyle.info=bold,black

option to maven. It also can be specified with MAVEN_OPTS environment variable in order not to type it on every maven invocation.

If you don't know which style is used in the particular part of output, you can match it by its default color.

The colors that can be used in a style are defined by jansi library:

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");
}

Seems that you can prefix color with bg to specify the background color, and to make it intensive, you add bold modifier, for example: bold,white,bgcyan — intensive white on cyan background.

Upvotes: 18

Tilman Hausherr
Tilman Hausherr

Reputation: 18861

When using maven inside Netbeans 8 the -D settings from the accepted answer won't work.

Solution: in the menu go to "Tools", "Options", in the Dialog to "Miscellaneus", "Output". On the right you'll see "Debug", "Warning", "Failure", "Success" and you can change the colors there. I used this to change the hard-to-see orange to a darker color.

Upvotes: 0

Related Questions