mvn.plugin.zsh 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. # mvn-color based on https://gist.github.com/1027800
  2. BOLD=`tput bold`
  3. UNDERLINE_ON=`tput smul`
  4. UNDERLINE_OFF=`tput rmul`
  5. TEXT_BLACK=`tput setaf 0`
  6. TEXT_RED=`tput setaf 1`
  7. TEXT_GREEN=`tput setaf 2`
  8. TEXT_YELLOW=`tput setaf 3`
  9. TEXT_BLUE=`tput setaf 4`
  10. TEXT_MAGENTA=`tput setaf 5`
  11. TEXT_CYAN=`tput setaf 6`
  12. TEXT_WHITE=`tput setaf 7`
  13. BACKGROUND_BLACK=`tput setab 0`
  14. BACKGROUND_RED=`tput setab 1`
  15. BACKGROUND_GREEN=`tput setab 2`
  16. BACKGROUND_YELLOW=`tput setab 3`
  17. BACKGROUND_BLUE=`tput setab 4`
  18. BACKGROUND_MAGENTA=`tput setab 5`
  19. BACKGROUND_CYAN=`tput setab 6`
  20. BACKGROUND_WHITE=`tput setab 7`
  21. RESET_FORMATTING=`tput sgr0`
  22. # Wrapper function for Maven's mvn command.
  23. mvn-color() {
  24. (
  25. # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
  26. unset LANG
  27. LC_CTYPE=C mvn $@ | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
  28. -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
  29. -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
  30. -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/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. }
  36. # Override the mvn command with the colorized one.
  37. #alias mvn="mvn-color"
  38. # aliases
  39. alias mvncie='mvn clean install eclipse:eclipse'
  40. alias mvnci='mvn clean install'
  41. alias mvncist='mvn clean install -DskipTests'
  42. alias mvncisto='mvn clean install -DskipTests --offline'
  43. alias mvne='mvn eclipse:eclipse'
  44. alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
  45. alias mvnd='mvn deploy'
  46. alias mvnp='mvn package'
  47. alias mvnc='mvn clean'
  48. alias mvncom='mvn compile'
  49. alias mvnct='mvn clean test'
  50. alias mvnt='mvn test'
  51. alias mvnag='mvn archetype:generate'
  52. alias mvn-updates='mvn versions:display-dependency-updates'
  53. alias mvntc7='mvn tomcat7:run'
  54. alias mvntc='mvn tomcat:run'
  55. alias mvnjetty='mvn jetty:run'
  56. alias mvndt='mvn dependency:tree'
  57. alias mvns='mvn site'
  58. alias mvnsrc='mvn dependency:sources'
  59. alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
  60. function listMavenCompletions {
  61. reply=(
  62. # common lifecycle
  63. clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site
  64. # common plugins
  65. deploy failsafe install site surefire checkstyle javadoc jxr pmd ant antrun archetype assembly dependency enforcer gpg help release repository source eclipse idea jetty cargo jboss tomcat tomcat6 tomcat7 exec versions war ear ejb android scm buildnumber nexus repository sonar license hibernate3 liquibase flyway gwt
  66. # deploy
  67. deploy:deploy-file
  68. # failsafe
  69. failsafe:integration-test failsafe:verify
  70. # install
  71. install:install-file
  72. # site
  73. site:site site:deploy site:run site:stage site:stage-deploy
  74. # surefire
  75. surefire:test
  76. # checkstyle
  77. checkstyle:checkstyle checkstyle:check
  78. # javadoc
  79. javadoc:javadoc javadoc:jar javadoc:aggregate
  80. # jxr
  81. jxr:jxr
  82. # pmd
  83. pmd:pmd pmd:cpd pmd:check pmd:cpd-check
  84. # ant
  85. ant:ant ant:clean
  86. # antrun
  87. antrun:run
  88. # archetype
  89. archetype:generate archetype:create-from-project archetype:crawl
  90. # assembly
  91. assembly:single assembly:assembly
  92. # dependency
  93. dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:get dependency:go-offline dependency:list dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
  94. # enforcer
  95. enforcer:enforce
  96. # gpg
  97. gpg:sign gpg:sign-and-deploy-file
  98. # help
  99. help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
  100. # release
  101. release:clean release:prepare release:rollback release:perform release:stage release:branch release:update-versions
  102. # jgitflow
  103. jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
  104. # repository
  105. repository:bundle-create repository:bundle-pack
  106. # source
  107. source:aggregate source:jar source:jar-no-fork
  108. # eclipse
  109. eclipse:clean eclipse:eclipse
  110. # idea
  111. idea:clean idea:idea
  112. # jetty
  113. jetty:run jetty:run-exploded
  114. # cargo
  115. cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
  116. # jboss
  117. jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
  118. # tomcat
  119. tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
  120. # tomcat6
  121. tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
  122. # tomcat7
  123. tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
  124. # tomee
  125. tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
  126. # spring-boot
  127. spring-boot:run spring-boot:repackage
  128. # exec
  129. exec:exec exec:java
  130. # versions
  131. versions:display-dependency-updates versions:display-plugin-updates versions:display-property-updates versions:update-parent versions:update-properties versions:update-child-modules versions:lock-snapshots versions:unlock-snapshots versions:resolve-ranges versions:set versions:use-releases versions:use-next-releases versions:use-latest-releases versions:use-next-snapshots versions:use-latest-snapshots versions:use-next-versions versions:use-latest-versions versions:commit versions:revert
  132. # scm
  133. scm:add scm:checkin scm:checkout scm:update scm:status
  134. # buildnumber
  135. buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
  136. # war
  137. war:war war:exploded war:inplace war:manifest
  138. # ear
  139. ear:ear ear:generate-application-xml
  140. # ejb
  141. ejb:ejb
  142. # android
  143. android:apk android:apklib android:deploy android:deploy-dependencies android:dex android:emulator-start android:emulator-stop android:emulator-stop-all android:generate-sources android:help android:instrument android:manifest-update android:pull android:push android:redeploy android:run android:undeploy android:unpack android:version-update android:zipalign android:devices
  144. # nexus
  145. nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
  146. # repository
  147. repository:bundle-create repository:bundle-pack repository:help
  148. # sonar
  149. sonar:sonar
  150. # license
  151. license:format license:check
  152. # hibernate3
  153. hibernate3:hbm2ddl hibernate3:help
  154. # liquibase
  155. liquibase:changelogSync liquibase:changelogSyncSQL liquibase:clearCheckSums liquibase:dbDoc liquibase:diff liquibase:dropAll liquibase:help liquibase:migrate liquibase:listLocks liquibase:migrateSQL liquibase:releaseLocks liquibase:rollback liquibase:rollbackSQL liquibase:status liquibase:tag liquibase:update liquibase:updateSQL liquibase:updateTestingRollback
  156. # flyway
  157. flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
  158. # gwt
  159. gwt:browser gwt:clean gwt:compile gwt:compile-report gwt:css gwt:debug gwt:eclipse gwt:eclipseTest gwt:generateAsync gwt:help gwt:i18n gwt:mergewebxml gwt:resources gwt:run gwt:sdkInstall gwt:source-jar gwt:soyc gwt:test
  160. # asciidoctor
  161. asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
  162. # options
  163. -Dmaven.test.skip=true -DskipTests -DskipITs -Dmaven.surefire.debug -DenableCiProfile -Dpmd.skip=true -Dcheckstyle.skip=true -Dtycho.mode=maven -Dmaven.test.failure.ignore=true -DgroupId= -DartifactId= -Dversion= -Dpackaging=jar -Dfile=
  164. # arguments
  165. -am -amd -B -C -c -cpu -D -e -emp -ep -f -fae -ff -fn -gs -h -l -N -npr -npu -nsu -o -P -pl -q -rf -s -T -t -U -up -V -v -X
  166. cli:execute cli:execute-phase
  167. archetype:generate generate-sources
  168. cobertura:cobertura
  169. -Dtest= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi`
  170. -Dit.test= `if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dit.test=\1?' ; fi`
  171. );
  172. }
  173. compctl -K listMavenCompletions mvn