Internationalization Cookbook
This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

Force maven “Run Configurations” to show colors

Once per Eclipse workspace: add an external maven installation

From “Preferences” go to “Maven” → “Installations” and click the “Add” button.

Preferences - Maven - Installations dialog

Make sure to choose the “External” radio button (default), and point “Installation home:” to the folder where you have a version of maven installed.

Adding Maven installation dialog

Click “Finish”, then “Apply and Close”.

Preferences - Maven - Installations dialog - with external maven installation

For each Maven Run Configuration: configure maven run target to force colors

From the main menu “Run” → “Run Configurations” select the “Maven Build” configuration you want to modify.

In the “Main” tab

At the very bottom make sure that the “Maven Runtime” is the EXTERNAL one you added before.
If it is not, select it from the dropdown.

Run configuration dialog - Main tab - Maven Runtime

In the table above that option click “Add” and add a parameter named style.color with the value always.

Run configuration dialog - JRE tab - add parameter

and click “OK”

Run configuration dialog - Main tab - all done

In the “JRE” tab

Go to the “VM arguments” area and add -Djansi.passthrough=true

Run configuration dialog - JRE tab - jansi passthrough

Run the modified maven run configuration

The output should show the colors you normally get in command line:

Maven output color in console - light

Maven output color in console - dark


This does not affect running maven tasks when you right-click on the project and choose “Run As” and “Maven clean” or “Maven install”.

Maven no color output with right-click


This is not a problem with the ANSI Console plugin.

It is caused by the fact that Maven and the Jansi library used by Maven try to detect if the current console is tty (not a redirect).
If they think it is, they refuse to output ANSI color escapes.

To force Maven to output color no matter the console type we need to set style.color=always.
To force Jansi to output color we need to set -Djansi.passthrough=true.

The third problem was with the Maven SLF4J binding in Eclipse.

The EMBEDDED maven that comes with Eclipse uses binds with SimpleLoggerFactory, which does not output colors.

This is why we have to use an external copy of maven, which comes with its own logger, MavenSimpleLogger.

So now you know the reason for each of the steps above.

And you also understand a bit better why the right-click “Run As” options don’t work: because there is no way to set the properties that force colors on Maven and Jansi

In order to get to this I had to dig in the Maven sources, Jansi sources, and some of the maven plugins that come with Eclipse :-)

I have a way to force the external maven on everything, and force Jansi to use colors, but not maven itself.
So I can get partial colors (log bevel, but no inside the messages (things like the current step, “BUILD SUCCESS”, and so on).
But this article does not explain how to achieve that.

I think it might be possible to fix everything, but it would be more intrusive.

Tags: , ,

Leave a comment