mvn.plugin.zsh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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. # if found an executable ./mvnw file execute it otherwise execute orignal mvn
  23. mvn-or-mvnw() {
  24. if [ -x ./mvnw ] ; then
  25. echo "executing mvnw instead of mvn"
  26. ./mvnw "$@";
  27. else
  28. mvn "$@";
  29. fi
  30. }
  31. # Wrapper function for Maven's mvn command.
  32. mvn-color() {
  33. (
  34. # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
  35. unset LANG
  36. LC_CTYPE=C mvn "$@" | sed -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
  37. -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
  38. -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
  39. -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
  40. -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"
  41. # Make sure formatting is reset
  42. echo -ne "${RESET_FORMATTING}"
  43. )
  44. }
  45. # Override the mvn command with the colorized one.
  46. #alias mvn="mvn-color"
  47. # either use orignal mvn oder the mvn wrapper
  48. alias mvn="mvn-or-mvnw"
  49. # aliases
  50. alias mvncie='mvn clean install eclipse:eclipse'
  51. alias mvnci='mvn clean install'
  52. alias mvncist='mvn clean install -DskipTests'
  53. alias mvncisto='mvn clean install -DskipTests --offline'
  54. alias mvne='mvn eclipse:eclipse'
  55. alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
  56. alias mvncv='mvn clean verify'
  57. alias mvnd='mvn deploy'
  58. alias mvnp='mvn package'
  59. alias mvnc='mvn clean'
  60. alias mvncom='mvn compile'
  61. alias mvnct='mvn clean test'
  62. alias mvnt='mvn test'
  63. alias mvnag='mvn archetype:generate'
  64. alias mvn-updates='mvn versions:display-dependency-updates'
  65. alias mvntc7='mvn tomcat7:run'
  66. alias mvntc='mvn tomcat:run'
  67. alias mvnjetty='mvn jetty:run'
  68. alias mvnboot='mvn spring-boot:run'
  69. alias mvndt='mvn dependency:tree'
  70. alias mvns='mvn site'
  71. alias mvnsrc='mvn dependency:sources'
  72. alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
  73. function listMavenCompletions {
  74. reply=(
  75. # common lifecycle
  76. clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site
  77. # common plugins
  78. 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
  79. # deploy
  80. deploy:deploy-file
  81. # failsafe
  82. failsafe:integration-test failsafe:verify
  83. # install
  84. install:install-file install:help
  85. # site
  86. site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
  87. # surefire
  88. surefire:test
  89. # checkstyle
  90. checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
  91. # javadoc
  92. javadoc:javadoc javadoc:test-javadoc javadoc:javadoc-no-fork javadoc:test-javadoc-no-fork javadoc:aggregate javadoc:test-aggregate javadoc:jar javadoc:test-jar javadoc:aggregate-jar javadoc:test-aggregate-jar javadoc:fix javadoc:test-fix javadoc:resource-bundle javadoc:test-resource-bundle
  93. # jxr
  94. jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
  95. # pmd
  96. pmd:pmd pmd:cpd pmd:check pmd:cpd-check
  97. # ant
  98. ant:ant ant:clean
  99. # antrun
  100. antrun:run
  101. # archetype
  102. archetype:generate archetype:create-from-project archetype:crawl
  103. # assembly
  104. assembly:single assembly:assembly
  105. # dependency
  106. dependency:analyze dependency:analyze-dep-mgt dependency:analyze-only dependency:analyze-report dependency:analyze-duplicate dependency:build-classpath dependency:copy dependency:copy-dependencies dependency:display-ancestors dependency:get dependency:go-offline dependency:list dependency:list-repositories dependency:properties dependency:purge-local-repository dependency:resolve dependency:resolve-plugins dependency:sources dependency:tree dependency:unpack dependency:unpack-dependencies
  107. # enforcer
  108. enforcer:enforce enforcer:display-info
  109. # gpg
  110. gpg:sign gpg:sign-and-deploy-file
  111. # help
  112. help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
  113. # release
  114. release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
  115. # jgitflow
  116. jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
  117. # repository
  118. repository:bundle-create repository:bundle-pack
  119. # source
  120. source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
  121. # eclipse
  122. eclipse:clean eclipse:eclipse
  123. # idea
  124. idea:clean idea:idea
  125. # jetty
  126. jetty:run jetty:run-exploded
  127. # cargo
  128. cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
  129. # jboss
  130. jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
  131. # tomcat
  132. tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
  133. # tomcat6
  134. tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
  135. # tomcat7
  136. tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
  137. # tomee
  138. tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
  139. # spring-boot
  140. spring-boot:run spring-boot:repackage
  141. # exec
  142. exec:exec exec:java
  143. # versions
  144. 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
  145. # scm
  146. scm:add scm:bootstrap scm:branch scm:changelog scm:check-local-modification scm:checkin scm:checkout scm:diff scm:edit scm:export scm:list scm:remove scm:status scm:tag scm:unedit scm:update scm:update-subprojects scm:validate
  147. # buildnumber
  148. buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
  149. # war
  150. war:war war:exploded war:inplace war:manifest
  151. # ear
  152. ear:ear ear:generate-application-xml
  153. # ejb
  154. ejb:ejb
  155. # android
  156. 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
  157. # nexus
  158. nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
  159. # repository
  160. repository:bundle-create repository:bundle-pack repository:help
  161. # sonar
  162. sonar:sonar
  163. # license
  164. license:format license:check
  165. # hibernate3
  166. hibernate3:hbm2ddl hibernate3:help
  167. # liquibase
  168. 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
  169. # flyway
  170. flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
  171. # gwt
  172. 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
  173. # asciidoctor
  174. asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
  175. # compiler
  176. compiler:compile compiler:testCompile
  177. # resources
  178. resources:resources resources:testResources resources:copy-resources
  179. # verifier
  180. verifier:verify
  181. # jar
  182. jar:jar jar:test-jar
  183. # rar
  184. rar:rar
  185. # acr
  186. acr:acr
  187. # shade
  188. shade:shade
  189. # changelog
  190. changelog:changelog changelog:dev-activity changelog:file-activity
  191. # changes
  192. changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
  193. # doap
  194. doap:generate
  195. # docck
  196. docck:check
  197. # jdeps
  198. jdeps:jdkinternals jdeps:test-jdkinternals
  199. # linkcheck
  200. linkcheck:linkcheck
  201. # project-info-reports
  202. project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:dependency-info project-info-reports:dependency-management project-info-reports:distribution-management project-info-reports:help project-info-reports:index project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:modules project-info-reports:plugin-management project-info-reports:plugins project-info-reports:project-team project-info-reports:scm project-info-reports:summary
  203. # surefire-report
  204. surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
  205. # invoker
  206. invoker:install invoker:integration-test invoker:verify invoker:run
  207. # jarsigner
  208. jarsigner:sign jarsigner:verify
  209. # patch
  210. patch:apply
  211. # pdf
  212. pdf:pdf
  213. # plugin
  214. plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
  215. # remote-resources
  216. remote-resources:bundle remote-resources:process
  217. # scm-publish
  218. scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
  219. # stage
  220. stage:copy
  221. # toolchain
  222. toolchain:toolchain
  223. # options
  224. "-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="
  225. # arguments
  226. -am --also-make
  227. -amd --also-make-dependents-am
  228. -B --batch-mode
  229. -b --builder
  230. -C --strict-checksums
  231. -c --lax-checksums
  232. -cpu --check-plugin-updates
  233. -D --define
  234. -e --errors
  235. -emp --encrypt-master-password
  236. -ep --encrypt-password
  237. -f --file
  238. -fae --fail-at-end
  239. -ff --fail-fast
  240. -fn --fail-never
  241. -gs --global-settings
  242. -gt --global-toolchains
  243. -h --help
  244. -l --log-file
  245. -llr --legacy-local-repository
  246. -N --non-recursive
  247. -npr --no-plugin-registry
  248. -npu --no-plugin-updates
  249. -nsu --no-snapshot-updates
  250. -o --offline
  251. -P --activate-profiles
  252. -pl --projects
  253. -q --quiet
  254. -rf --resume-from
  255. -s --settings
  256. -t --toolchains
  257. -T --threads
  258. -U --update-snapshots
  259. -up --update-plugins
  260. -v --version
  261. -V --show-version
  262. -X --debug
  263. cli:execute cli:execute-phase
  264. archetype:generate generate-sources
  265. cobertura:cobertura
  266. -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
  267. -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)
  268. );
  269. }
  270. compctl -K listMavenCompletions mvn
  271. compctl -K listMavenCompletions mvn-or-mvnw