From 15e0dc9ec937d98094419b59a89be60fe6dbff3f Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Tue, 6 Nov 2012 15:39:59 -0200 Subject: [PATCH] Added some maven love. --- plugins/mvn/mvn.color.plugin.zsh | 41 ++++++++++++++++++++++++++++++++ plugins/mvn/mvn.plugin.zsh | 14 ++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 plugins/mvn/mvn.color.plugin.zsh diff --git a/plugins/mvn/mvn.color.plugin.zsh b/plugins/mvn/mvn.color.plugin.zsh new file mode 100644 index 00000000..82281a70 --- /dev/null +++ b/plugins/mvn/mvn.color.plugin.zsh @@ -0,0 +1,41 @@ +# mvn-color based on https://gist.github.com/1027800 +export BOLD=`tput bold` +export UNDERLINE_ON=`tput smul` +export UNDERLINE_OFF=`tput rmul` +export TEXT_BLACK=`tput setaf 0` +export TEXT_RED=`tput setaf 1` +export TEXT_GREEN=`tput setaf 2` +export TEXT_YELLOW=`tput setaf 3` +export TEXT_BLUE=`tput setaf 4` +export TEXT_MAGENTA=`tput setaf 5` +export TEXT_CYAN=`tput setaf 6` +export TEXT_WHITE=`tput setaf 7` +export BACKGROUND_BLACK=`tput setab 0` +export BACKGROUND_RED=`tput setab 1` +export BACKGROUND_GREEN=`tput setab 2` +export BACKGROUND_YELLOW=`tput setab 3` +export BACKGROUND_BLUE=`tput setab 4` +export BACKGROUND_MAGENTA=`tput setab 5` +export BACKGROUND_CYAN=`tput setab 6` +export BACKGROUND_WHITE=`tput setab 7` +export RESET_FORMATTING=`tput sgr0` + + +# Wrapper function for Maven's mvn command. +mvn-color() +{ + # Filter mvn output using sed + mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \ + -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \ + -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \ + -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \ + -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \ + -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" + + # Make sure formatting is reset + echo -ne ${RESET_FORMATTING} +} + +# Override the mvn command with the colorized one. +alias mvn="mvn-color" + diff --git a/plugins/mvn/mvn.plugin.zsh b/plugins/mvn/mvn.plugin.zsh index e8af2f49..66d18074 100644 --- a/plugins/mvn/mvn.plugin.zsh +++ b/plugins/mvn/mvn.plugin.zsh @@ -1,6 +1,18 @@ +# aliases +alias mvncie='mvn clean install eclipse:eclipse' +alias mvnci='mvn clean install' +alias mvne='mvn eclipse:eclipse' +alias mvnce='mvn clean eclipse:clean eclipse:eclipse' +alias mvnd='mvn deploy' +alias mvnp='mvn package' +alias mvnc='mvn clean' +alias mvncom='mvn compile' +alias mvnt='mvn test' +alias mvnag='mvn archetype:generate' + function listMavenCompletions { reply=( cli:execute cli:execute-phase archetype:generate generate-sources compile clean install test test-compile deploy package cobertura:cobertura jetty:run gwt:run gwt:debug -DskipTests -Dmaven.test.skip=true -DarchetypeCatalog=http://tapestry.formos.com/maven-snapshot-repository -Dtest= `if [ -d ./src ] ; then find ./src -type f | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi`); } -compctl -K listMavenCompletions mvn \ No newline at end of file +compctl -K listMavenCompletions mvn