Created
March 29, 2012 08:26
-
-
Save wadouk/2234957 to your computer and use it in GitHub Desktop.
Maven console in color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PURPLE=$(echo -en "\033[35m") | |
GREEN=$(echo -en "\033[32m") | |
RED=$(echo -en "\033[31m") | |
YELLOW=$(echo -e "\033[33m") | |
BLUE=$(echo -e "\033[1;34m") | |
NORMAL=$(echo -e "\033[0m") | |
mvn2() { | |
mvn $* | sed \ | |
-e "s/^\(.ERROR. .*\)$/$RED\1$NORMAL/ ; #contain ERROR start 2nd char | |
s/^\(Tests run: .*<<< FAILURE\!\)/$RED\1$NORMAL/ ; # contain Tests run: <something> <<< FAILURE | |
s/^\( \w*\\([\w\.]*\\).*: .*\)/$RED\1$NORMAL/ ; # a name of method(name of class with package): error message | |
s/^\(Failed tests:.*\)/$RED\1$NORMAL/ ; # contain Failed tests: | |
s/^\(|.*\)/$RED\1$NORMAL/ ; # line start with pipe | |
s/^\(### Content of table.*\)/$RED\1$NORMAL/ ; # line start ### Content of table (dbunit) | |
s/^\(Caused by*.*\)/$RED\1$NORMAL/ ; # line start Caused by | |
s/^\(\tat .*\)/$RED\1$NORMAL/ ; # line start at ... (stack trace) | |
s/^\(\t*.*more.*\)/$RED\1$NORMAL/ ; # line start with tab and contain something with more (stack trace) | |
s/^\(##*.*\)/$RED\1$NORMAL/ ; # line start more than 1 # | |
s/^\(Running.*\)/$BLUE\1$NORMAL/ ; # Line start with Running (surefire) | |
s/^\(Tests run: .*[^FAILURE].*\)/${YELLOW}\1${NORMAL}/ ; # test not failed | |
s/^\(.INFO. BUILD FAILURE.*\)$/$RED\1$NORMAL/ ; # BUILD FAILURE | |
s/^\(.INFO. ----.*\)$/$PURPLE\1$NORMAL/ ; # INFO of module block | |
s/^\(.INFO. Building.*SNAPSHOT\)$/$PURPLE\1$NORMAL/; # INFO of module block (with version) | |
s/^\(.INFO. --- .* ---.*\)$/$PURPLE\1$NORMAL/ ; # info of plugin | |
s/^\(.INFO. .*\)$/$GREEN\1$NORMAL/ ; # other info | |
s/^\(.WARNING. .*\)$/$BLUE\1$NORMAL/ ; # warning | |
s/^\(\w*\.\w*\) \(r [0-9]* w 0 e 0 .* seconds.*\)$/$BLUE\1$NORMAL $YELLOW\2$NORMAL/; | |
s/^\(\w*\.\w*\) \(r [0-9]* w [1-9] e 0 .* seconds.*\)$/$RED\1 \2$NORMAL/; | |
s/^\(\w*\.\w*\) \(r [0-9]* w [1-9] e [1-9] .* seconds.*\)$/$RED\1 \2$NORMAL/; | |
s/^\(\w*\.\w*\) \(r [0-9]* w 0 e [1-9] .* seconds.*\)$/$RED\1 \2$NORMAL/; | |
# Fitnesse execute test; | |
s/^\([^\[].*\)/${YELLOW}\1${NORMAL}/ ; # line doesn't start with [ | |
" | |
} | |
alias mci='mvn2 clean install' | |
alias mcit='mvn2 clean install -DskipTests' | |
alias mrr='mvn2 resources:testResources' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!
I found it useful to add
s/^(.FAILURE.)$/$RED\1$NORMAL/ ; # contains FAILURE somewhere in the message
to the mix, so that lines emitted by running maven on multiple projects are also painted red in case of failure.
For instance:
[INFO] MyPrj1 ........................................... SUCCESS [0.241s] ### should be, and is, green.
[INFO] MyPrj2 ........................................... FAILURE [0.245s] #### should be red, but wasn't.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE ### should be, and is, red.
[INFO] ------------------------------------------------------------------------
Thanks for sharing!