3 # Original script from:
4 # http://johannes.jakeapp.com/blog/category/fun-with-linux/200901/maven-colorized
5 # http://ju-n.net/colorize-maven-output
8 export BOLD
=`tput bold`
9 export UNDERLINE_ON
=`tput smul`
10 export UNDERLINE_OFF
=`tput rmul`
11 export TEXT_BLACK
=`tput setaf 0`
12 export TEXT_RED
=`tput setaf 1`
13 export TEXT_GREEN
=`tput setaf 2`
14 export TEXT_YELLOW
=`tput setaf 3`
15 export TEXT_BLUE
=`tput setaf 4`
16 export TEXT_MAGENTA
=`tput setaf 5`
17 export TEXT_CYAN
=`tput setaf 6`
18 export TEXT_WHITE
=`tput setaf 7`
19 export BACKGROUND_BLACK
=`tput setab 0`
20 export BACKGROUND_RED
=`tput setab 1`
21 export BACKGROUND_GREEN
=`tput setab 2`
22 export BACKGROUND_YELLOW
=`tput setab 3`
23 export BACKGROUND_BLUE
=`tput setab 4`
24 export BACKGROUND_MAGENTA
=`tput setab 5`
25 export BACKGROUND_CYAN
=`tput setab 6`
26 export BACKGROUND_WHITE
=`tput setab 7`
27 export RESET_FORMATTING
=`tput sgr0`
29 # Wrapper function for Maven's mvn-2.2 command.
32 # Filter mvn output using sed
33 mvn
"$@" |
sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
34 -e "s/\(^-----.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
35 -e "s/\(^ T E S T S.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
36 -e "s/\(\[INFO\] \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
37 -e "s/\(\[INFO\] BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
38 -e "s/\(\[INFO\] Building module \)\(.*\)/${BOLD}${TEXT_BLUE}\1${TEXT_GREEN}\2${RESET_FORMATTING}/g" \
39 -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
40 -e "s/\([0-9]*) [^:]*:[^:]*:[^:]*:.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
41 -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
42 -e "s/\(\[INFO\] Failed to resolve artifact\\..*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
43 -e "s/\(Exception in thread \"[^\"]*\" \)\(.*\)/\1${BOLD}${TEXT_RED}\2${RESET_FORMATTING}/g" \
44 -e "s/\(Caused by: \)\([^:\t ]*\)/\1${BOLD}${TEXT_RED}\2${RESET_FORMATTING}/g" \
45 -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
47 # Make sure formatting is reset
48 echo -ne ${RESET_FORMATTING}
51 # Wrapper function for Maven's mvn-3.0 command.
54 # Filter mvn output using sed
56 -e "s/\(\[INFO\]\ ---\ .*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
57 -e "s/\(\[INFO\]\ <<<\ .*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
58 -e "s/\(\[INFO\]\ >>>\ .*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
59 -e "s/\(\[INFO\]\ BUILD SUCCESS\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
60 -e "s/\(\[INFO\]\ -----.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
61 -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
62 -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
63 -e "s/\(Exception in thread \"[^\"]*\" \)\(.*\)/\1${BOLD}${TEXT_RED}\2${RESET_FORMATTING}/g" \
64 -e "s/\(Caused by: \)\([^:\t ]*\)/\1${BOLD}${TEXT_RED}\2${RESET_FORMATTING}/g" \
65 -e "s/\(^ T E S T S.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
66 -e "s/\(^-----.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}/g" \
67 -e "s/Tests run: \([^,]*\), Failures: \([^,]*\), Errors: \([^,]*\), Skipped: \([^,]*\)/${BOLD}${TEXT_GREEN}Tests run: \1${RESET_FORMATTING}, Failures: ${BOLD}${TEXT_RED}\2${RESET_FORMATTING}, Errors: ${BOLD}${TEXT_RED}\3${RESET_FORMATTING}, Skipped: ${BOLD}${TEXT_YELLOW}\4${RESET_FORMATTING}/g"
69 # -e "s/\([0-9*]) [^:]*:[^:]*:[^:]*:.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
70 # -e "s/\(\[INFO\] Failed to resolve artifact\\..*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
72 # Make sure formatting is reset
73 echo -ne ${RESET_FORMATTING}
76 MVN_BIN
=`realpath /usr/bin/mvn | grep -o -E '[0-9]*[.][0-9]*'`
80 echo "[INFO] Maven-color disabled (Maven 1.x not supported.)"
90 echo "Unknovn maven version $MVN_BIN"