Maven in colour / Maven en couleur
Par Olivier le lundi 20 octobre 2008, 19:05 - Lien permanent
ENG : If you want to see maven in colour, you can just add an litle awk in a script :)
FR : Vous voulez voir maven en couleur, il suffit d'ajouter un petit awk dans un script :)
ENG : If you want to see maven in colour, you can just add an litle awk in a script :)
FR : Vous voulez voir maven en couleur, il suffit d'ajouter un petit awk dans un script :)
sudo vi /usr/local/bin/mvnc
#!/bin/sh
mvn $@ 2>&1 | awk '
($1 == "[ALL]") { print "\033[1;37m" $0 "\033[0m"; next; }
($1 == "[FATAL]") { print "\033[1;31m" $0 "\033[0m"; next; }
($1 == "[ERROR]") { print "\033[1;31m" $0 "\033[0m"; next; }
($1 == "[WARNING]") { print "\033[1;33m" $0 "\033[0m"; next; }
($1 == "[INFO]") { print "\033[1;37m" $0 "\033[0m"; next; }
($1 == "[DEBUG]") { print "\033[1;36m" $0 "\033[0m"; next; }
($1 == "[TRACE]") { print "\033[1;32m" $0 "\033[0m"; next; }
{ print }'
vi ~/.bashrc
... alias mvn='JAVA_HOME=~/java/jdk/jdk6; mvnc' ...


Commentaires
[WARNING] Don't use this to run interactive goals (eg mvn release:prepare), because you won't see prompts unless they end with newline. Don't ask me how I know, or how long it took to work out what was going on...
Other than that, having colour output from Maven is great. There's a colour patch for Maven logging at http://jira.codehaus.org/browse/MNG... .