mvn.plugin.zsh 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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 mvncv='mvn clean verify'
  46. alias mvnd='mvn deploy'
  47. alias mvnp='mvn package'
  48. alias mvnc='mvn clean'
  49. alias mvncom='mvn compile'
  50. alias mvnct='mvn clean test'
  51. alias mvnt='mvn test'
  52. alias mvnag='mvn archetype:generate'
  53. alias mvn-updates='mvn versions:display-dependency-updates'
  54. alias mvntc7='mvn tomcat7:run'
  55. alias mvntc='mvn tomcat:run'
  56. alias mvnjetty='mvn jetty:run'
  57. alias mvndt='mvn dependency:tree'
  58. alias mvns='mvn site'
  59. alias mvnsrc='mvn dependency:sources'
  60. alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
  61. function listMavenCompletions {
  62. reply=(
  63. # common lifecycle
  64. clean process-resources compile process-test-resources test-compile test integration-test package verify install deploy site
  65. # common plugins
  66. 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
  67. # deploy
  68. deploy:deploy-file
  69. # failsafe
  70. failsafe:integration-test failsafe:verify
  71. # install
  72. install:install-file install:help
  73. # site
  74. site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
  75. # surefire
  76. surefire:test
  77. # checkstyle
  78. checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
  79. # javadoc
  80. 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
  81. # jxr
  82. jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
  83. # pmd
  84. pmd:pmd pmd:cpd pmd:check pmd:cpd-check
  85. # ant
  86. ant:ant ant:clean
  87. # antrun
  88. antrun:run
  89. # archetype
  90. archetype:generate archetype:create-from-project archetype:crawl
  91. # assembly
  92. assembly:single assembly:assembly
  93. # dependency
  94. 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
  95. # enforcer
  96. enforcer:enforce enforcer:display-info
  97. # gpg
  98. gpg:sign gpg:sign-and-deploy-file
  99. # help
  100. help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
  101. # release
  102. release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
  103. # jgitflow
  104. jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
  105. # repository
  106. repository:bundle-create repository:bundle-pack
  107. # source
  108. source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
  109. # eclipse
  110. eclipse:clean eclipse:eclipse
  111. # idea
  112. idea:clean idea:idea
  113. # jetty
  114. jetty:run jetty:run-exploded
  115. # cargo
  116. cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
  117. # jboss
  118. jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
  119. # tomcat
  120. tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
  121. # tomcat6
  122. tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
  123. # tomcat7
  124. tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
  125. # tomee
  126. tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
  127. # spring-boot
  128. spring-boot:run spring-boot:repackage
  129. # exec
  130. exec:exec exec:java
  131. # versions
  132. 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
  133. # scm
  134. 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
  135. # buildnumber
  136. buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
  137. # war
  138. war:war war:exploded war:inplace war:manifest
  139. # ear
  140. ear:ear ear:generate-application-xml
  141. # ejb
  142. ejb:ejb
  143. # android
  144. 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
  145. # nexus
  146. nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
  147. # repository
  148. repository:bundle-create repository:bundle-pack repository:help
  149. # sonar
  150. sonar:sonar
  151. # license
  152. license:format license:check
  153. # hibernate3
  154. hibernate3:hbm2ddl hibernate3:help
  155. # liquibase
  156. 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
  157. # flyway
  158. flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
  159. # gwt
  160. 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
  161. # asciidoctor
  162. asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
  163. # compiler
  164. compiler:compile compiler:testCompile
  165. # resources
  166. resources:resources resources:testResources resources:copy-resources
  167. # verifier
  168. verifier:verify
  169. # jar
  170. jar:jar jar:test-jar
  171. # rar
  172. rar:rar
  173. # acr
  174. acr:acr
  175. # shade
  176. shade:shade
  177. # changelog
  178. changelog:changelog changelog:dev-activity changelog:file-activity
  179. # changes
  180. changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
  181. # doap
  182. doap:generate
  183. # docck
  184. docck:check
  185. # jdeps
  186. jdeps:jdkinternals jdeps:test-jdkinternals
  187. # linkcheck
  188. linkcheck:linkcheck
  189. # project-info-reports
  190. 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
  191. # surefire-report
  192. surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
  193. # invoker
  194. invoker:install invoker:integration-test invoker:verify invoker:run
  195. # jarsigner
  196. jarsigner:sign jarsigner:verify
  197. # patch
  198. patch:apply
  199. # pdf
  200. pdf:pdf
  201. # plugin
  202. plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
  203. # remote-resources
  204. remote-resources:bundle remote-resources:process
  205. # scm-publish
  206. scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
  207. # stage
  208. stage:copy
  209. # toolchain
  210. toolchain:toolchain
  211. # options
  212. "-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="
  213. # arguments
  214. -am --also-make
  215. -amd --also-make-dependents-am
  216. -B --batch-mode
  217. -b --builder
  218. -C --strict-checksums
  219. -c --lax-checksums
  220. -cpu --check-plugin-updates
  221. -D --define
  222. -e --errors
  223. -emp --encrypt-master-password
  224. -ep --encrypt-password
  225. -f --file
  226. -fae --fail-at-end
  227. -ff --fail-fast
  228. -fn --fail-never
  229. -gs --global-settings
  230. -gt --global-toolchains
  231. -h --help
  232. -l --log-file
  233. -llr --legacy-local-repository
  234. -N --non-recursive
  235. -npr --no-plugin-registry
  236. -npu --no-plugin-updates
  237. -nsu --no-snapshot-updates
  238. -o --offline
  239. -P --activate-profiles
  240. -pl --projects
  241. -q --quiet
  242. -rf --resume-from
  243. -s --settings
  244. -t --toolchains
  245. -T --threads
  246. -U --update-snapshots
  247. -up --update-plugins
  248. -v --version
  249. -V --show-version
  250. -X --debug
  251. cli:execute cli:execute-phase
  252. archetype:generate generate-sources
  253. cobertura:cobertura
  254. -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
  255. -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)
  256. );
  257. }
  258. compctl -K listMavenCompletions mvn