mvn.plugin.zsh 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # mvn-color based on https://gist.github.com/1027800
  2. export BOLD=`tput bold`
  3. export UNDERLINE_ON=`tput smul`
  4. export UNDERLINE_OFF=`tput rmul`
  5. export TEXT_BLACK=`tput setaf 0`
  6. export TEXT_RED=`tput setaf 1`
  7. export TEXT_GREEN=`tput setaf 2`
  8. export TEXT_YELLOW=`tput setaf 3`
  9. export TEXT_BLUE=`tput setaf 4`
  10. export TEXT_MAGENTA=`tput setaf 5`
  11. export TEXT_CYAN=`tput setaf 6`
  12. export TEXT_WHITE=`tput setaf 7`
  13. export BACKGROUND_BLACK=`tput setab 0`
  14. export BACKGROUND_RED=`tput setab 1`
  15. export BACKGROUND_GREEN=`tput setab 2`
  16. export BACKGROUND_YELLOW=`tput setab 3`
  17. export BACKGROUND_BLUE=`tput setab 4`
  18. export BACKGROUND_MAGENTA=`tput setab 5`
  19. export BACKGROUND_CYAN=`tput setab 6`
  20. export BACKGROUND_WHITE=`tput setab 7`
  21. export RESET_FORMATTING=`tput sgr0`
  22. # Wrapper function for Maven's mvn command.
  23. mvn-color()
  24. {
  25. # Filter mvn output using sed
  26. mvn $@ | sed -e "s/\(\[INFO\]\ \-.*\)/${TEXT_BLUE}${BOLD}\1/g" \
  27. -e "s/\(\[INFO\]\ \[.*\)/${RESET_FORMATTING}${BOLD}\1${RESET_FORMATTING}/g" \
  28. -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
  29. -e "s/\(\[WARNING\].*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}/g" \
  30. -e "s/\(\[ERROR\].*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}/g" \
  31. -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"
  32. # Make sure formatting is reset
  33. echo -ne ${RESET_FORMATTING}
  34. }
  35. # Override the mvn command with the colorized one.
  36. #alias mvn="mvn-color"
  37. # aliases
  38. alias mvncie='mvn clean install eclipse:eclipse'
  39. alias mvnci='mvn clean install'
  40. alias mvne='mvn eclipse:eclipse'
  41. alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
  42. alias mvnd='mvn deploy'
  43. alias mvnp='mvn package'
  44. alias mvnc='mvn clean'
  45. alias mvncom='mvn compile'
  46. alias mvnt='mvn test'
  47. alias mvnag='mvn archetype:generate'
  48. function listMavenCompletions {
  49. reply=(
  50. 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`);
  51. }
  52. compctl -K listMavenCompletions mvn