my xfce4 dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

342 lines
14 KiB

3 years ago
  1. # Calls mvnw if found in the current project, otherwise execute the original mvn
  2. mvn-or-mvnw() {
  3. local dir="$PWD"
  4. while [[ ! -x "$dir/mvnw" && "$dir" != / ]]; do
  5. dir="${dir:h}"
  6. done
  7. if [[ -x "$dir/mvnw" ]]; then
  8. echo "Running \`$dir/mvnw\`..." >&2
  9. "$dir/mvnw" "$@"
  10. return $?
  11. fi
  12. command mvn "$@"
  13. }
  14. # Wrapper function for Maven's mvn command. Based on https://gist.github.com/1027800
  15. mvn-color() {
  16. local BOLD=$(echoti bold)
  17. local TEXT_RED=$(echoti setaf 1)
  18. local TEXT_GREEN=$(echoti setaf 2)
  19. local TEXT_YELLOW=$(echoti setaf 3)
  20. local TEXT_BLUE=$(echoti setaf 4)
  21. local TEXT_WHITE=$(echoti setaf 7)
  22. local RESET_FORMATTING=$(echoti sgr0)
  23. (
  24. # Filter mvn output using sed. Before filtering set the locale to C, so invalid characters won't break some sed implementations
  25. unset LANG
  26. LC_CTYPE=C mvn "$@" | sed \
  27. -e "s/\(\[INFO\]\)\(.*\)/${TEXT_BLUE}${BOLD}\1${RESET_FORMATTING}\2/g" \
  28. -e "s/\(\[DEBUG\]\)\(.*\)/${TEXT_WHITE}${BOLD}\1${RESET_FORMATTING}\2/g" \
  29. -e "s/\(\[INFO\]\ BUILD SUCCESSFUL\)/${BOLD}${TEXT_GREEN}\1${RESET_FORMATTING}/g" \
  30. -e "s/\(\[WARNING\]\)\(.*\)/${BOLD}${TEXT_YELLOW}\1${RESET_FORMATTING}\2/g" \
  31. -e "s/\(\[ERROR\]\)\(.*\)/${BOLD}${TEXT_RED}\1${RESET_FORMATTING}\2/g" \
  32. -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"
  33. # Make sure formatting is reset
  34. echo -ne "${RESET_FORMATTING}"
  35. )
  36. }
  37. # either use original mvn or the mvn wrapper
  38. alias mvn="mvn-or-mvnw"
  39. # Run mvn against the pom found in a project's root directory (assumes a git repo)
  40. alias 'mvn!'='mvn -f $(git rev-parse --show-toplevel 2>/dev/null || echo ".")/pom.xml'
  41. # aliases
  42. alias mvnag='mvn archetype:generate'
  43. alias mvnboot='mvn spring-boot:run'
  44. alias mvnc='mvn clean'
  45. alias mvncd='mvn clean deploy'
  46. alias mvnce='mvn clean eclipse:clean eclipse:eclipse'
  47. alias mvnci='mvn clean install'
  48. alias mvncie='mvn clean install eclipse:eclipse'
  49. alias mvncini='mvn clean initialize'
  50. alias mvncist='mvn clean install -DskipTests'
  51. alias mvncisto='mvn clean install -DskipTests --offline'
  52. alias mvncom='mvn compile'
  53. alias mvncp='mvn clean package'
  54. alias mvnct='mvn clean test'
  55. alias mvncv='mvn clean verify'
  56. alias mvncvst='mvn clean verify -DskipTests'
  57. alias mvnd='mvn deploy'
  58. alias mvndocs='mvn dependency:resolve -Dclassifier=javadoc'
  59. alias mvndt='mvn dependency:tree'
  60. alias mvne='mvn eclipse:eclipse'
  61. alias mvnfmt='mvn fmt:format'
  62. alias mvnjetty='mvn jetty:run'
  63. alias mvnp='mvn package'
  64. alias mvnqdev='mvn quarkus:dev'
  65. alias mvns='mvn site'
  66. alias mvnsrc='mvn dependency:sources'
  67. alias mvnt='mvn test'
  68. alias mvntc='mvn tomcat:run'
  69. alias mvntc7='mvn tomcat7:run'
  70. alias mvn-updates='mvn versions:display-dependency-updates'
  71. function listMavenCompletions {
  72. local file new_file
  73. local -a profiles POM_FILES modules
  74. # Root POM
  75. POM_FILES=(~/.m2/settings.xml)
  76. # POM in the current directory
  77. if [[ -f pom.xml ]]; then
  78. local file=pom.xml
  79. POM_FILES+=("${file:A}")
  80. fi
  81. # Look for POM files in parent directories
  82. while [[ -n "$file" ]] && grep -q "<parent>" "$file"; do
  83. # look for a new relativePath for parent pom.xml
  84. new_file=$(grep -e "<relativePath>.*</relativePath>" "$file" | sed -e 's/.*<relativePath>\(.*\)<\/relativePath>.*/\1/')
  85. # if <parent> is present but not defined, assume ../pom.xml
  86. if [[ -z "$new_file" ]]; then
  87. new_file="../pom.xml"
  88. fi
  89. # if file doesn't exist break
  90. file="${file:h}/${new_file}"
  91. if ! [[ -e "$file" ]]; then
  92. break
  93. fi
  94. POM_FILES+=("${file:A}")
  95. done
  96. # Get profiles from found files
  97. for file in $POM_FILES; do
  98. [[ -e $file ]] || continue
  99. profiles+=($(sed 's/<!--.*-->//' "$file" | sed '/<!--/,/-->/d' | grep -e "<profile>" -A 1 | grep -e "<id>.*</id>" | sed 's?.*<id>\(.*\)<\/id>.*?-P\1?'))
  100. done
  101. # List modules
  102. modules=($(print -l **/pom.xml(-.N:h) | grep -v '/target/classes/META-INF/'))
  103. reply=(
  104. # common lifecycle
  105. clean initialize process-resources compile process-test-resources test-compile test package verify install deploy site
  106. # integration testing
  107. pre-integration-test integration-test
  108. # common plugins
  109. 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
  110. # deploy
  111. deploy:deploy-file
  112. # failsafe
  113. failsafe:integration-test failsafe:verify
  114. # install
  115. install:install-file install:help
  116. # site
  117. site:site site:deploy site:run site:stage site:stage-deploy site:attach-descriptor site:jar site:effective-site
  118. # surefire
  119. surefire:test
  120. # checkstyle
  121. checkstyle:checkstyle checkstyle:check checkstyle:checkstyle-aggregate
  122. # javadoc
  123. 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
  124. # jxr
  125. jxr:jxr jxr:aggregate jxr:test-jxr jxr:test-aggregate
  126. # pmd
  127. pmd:pmd pmd:cpd pmd:check pmd:cpd-check
  128. # ant
  129. ant:ant ant:clean
  130. # antrun
  131. antrun:run
  132. # archetype
  133. archetype:generate archetype:create-from-project archetype:crawl
  134. # assembly
  135. assembly:single assembly:assembly
  136. # dependency
  137. 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
  138. # enforcer
  139. enforcer:enforce enforcer:display-info
  140. # gpg
  141. gpg:sign gpg:sign-and-deploy-file
  142. # help
  143. help:active-profiles help:all-profiles help:describe help:effective-pom help:effective-settings help:evaluate help:expressions help:system
  144. # release
  145. release:clean release:prepare release:prepare-with-pom release:rollback release:perform release:stage release:branch release:update-versions
  146. # jgitflow
  147. jgitflow:feature-start jgitflow:feature-finish jgitflow:release-start jgitflow:release-finish jgitflow:hotfix-start jgitflow:hotfix-finish jgitflow:build-number
  148. # repository
  149. repository:bundle-create repository:bundle-pack
  150. # source
  151. source:aggregate source:jar source:jar-no-fork source:test-jar source:test-jar-no-fork
  152. # eclipse
  153. eclipse:clean eclipse:eclipse
  154. # idea
  155. idea:clean idea:idea
  156. # jetty
  157. jetty:run jetty:run-exploded
  158. # cargo
  159. cargo:start cargo:run cargo:stop cargo:deploy cargo:undeploy cargo:help
  160. # jboss
  161. jboss:start jboss:stop jboss:deploy jboss:undeploy jboss:redeploy
  162. # tomcat
  163. tomcat:start tomcat:stop tomcat:deploy tomcat:undeploy tomcat:redeploy
  164. # tomcat6
  165. tomcat6:run tomcat6:run-war tomcat6:run-war-only tomcat6:stop tomcat6:deploy tomcat6:undeploy
  166. # tomcat7
  167. tomcat7:run tomcat7:run-war tomcat7:run-war-only tomcat7:deploy
  168. # tomee
  169. tomee:run tomee:run-war tomee:run-war-only tomee:stop tomee:deploy tomee:undeploy
  170. # spring-boot
  171. spring-boot:run spring-boot:repackage
  172. # quarkus
  173. quarkus:dev quarkus:list-extensions quarkus:add-extension quarkus:add-extensions quarkus:generate-config quarkus:help
  174. # exec
  175. exec:exec exec:java
  176. # versions
  177. 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
  178. # scm
  179. 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
  180. # buildnumber
  181. buildnumber:create buildnumber:create-timestamp buildnumber:help buildnumber:hgchangeset
  182. # war
  183. war:war war:exploded war:inplace war:manifest
  184. # ear
  185. ear:ear ear:generate-application-xml
  186. # ejb
  187. ejb:ejb
  188. # android
  189. 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
  190. # nexus
  191. nexus:staging-list nexus:staging-close nexus:staging-drop nexus:staging-release nexus:staging-build-promotion nexus:staging-profiles-list nexus:settings-download
  192. # repository
  193. repository:bundle-create repository:bundle-pack repository:help
  194. # sonar
  195. sonar:sonar
  196. # license
  197. license:format license:check
  198. # hibernate3
  199. hibernate3:hbm2ddl hibernate3:help
  200. # liquibase
  201. 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
  202. # flyway
  203. flyway:clean flyway:history flyway:init flyway:migrate flyway:status flyway:validate
  204. # gwt
  205. 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
  206. # asciidoctor
  207. asciidoctor:process-asciidoc asciidoctor:auto-refresh asciidoctor:http asciidoctor:zip
  208. # compiler
  209. compiler:compile compiler:testCompile
  210. # resources
  211. resources:resources resources:testResources resources:copy-resources
  212. # verifier
  213. verifier:verify
  214. # jar
  215. jar:jar jar:test-jar
  216. # rar
  217. rar:rar
  218. # acr
  219. acr:acr
  220. # shade
  221. shade:shade
  222. # changelog
  223. changelog:changelog changelog:dev-activity changelog:file-activity
  224. # changes
  225. changes:announcement-mail changes:announcement-generate changes:changes-check changes:changes-validate changes:changes-report changes:jira-report changes:trac-report changes:github-report
  226. # doap
  227. doap:generate
  228. # docck
  229. docck:check
  230. # jdeps
  231. jdeps:jdkinternals jdeps:test-jdkinternals
  232. # linkcheck
  233. linkcheck:linkcheck
  234. # project-info-reports
  235. 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
  236. # surefire-report
  237. surefire-report:failsafe-report-only surefire-report:report surefire-report:report-only
  238. # invoker
  239. invoker:install invoker:integration-test invoker:verify invoker:run
  240. # jarsigner
  241. jarsigner:sign jarsigner:verify
  242. # patch
  243. patch:apply
  244. # pdf
  245. pdf:pdf
  246. # plugin
  247. plugin:descriptor plugin:report plugin:updateRegistry plugin:addPluginArtifactMetadata plugin:helpmojo
  248. # remote-resources
  249. remote-resources:bundle remote-resources:process
  250. # scm-publish
  251. scm-publish:help scm-publish:publish-scm scm-publish:scmpublish
  252. # stage
  253. stage:copy
  254. # toolchain
  255. toolchain:toolchain
  256. #liberty
  257. liberty:clean-server liberty:compile-jsp liberty:configure-arquillian liberty:create-server liberty:debug liberty:debug-server liberty:deploy liberty:dev liberty:display-url liberty:dump-server liberty:install-apps liberty:install-feature liberty:install-server liberty:java-dump-server liberty:package-server liberty:run liberty:run-server liberty:server-status liberty:start liberty:start-server liberty:status liberty:stop liberty:stop-server liberty:test-start-server liberty:test-stop-server liberty:undeploy liberty:uninstall-feature
  258. # options
  259. "-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="
  260. # arguments
  261. -am --also-make
  262. -amd --also-make-dependents-am
  263. -B --batch-mode
  264. -b --builder
  265. -C --strict-checksums
  266. -c --lax-checksums
  267. -cpu --check-plugin-updates
  268. -D --define
  269. -e --errors
  270. -emp --encrypt-master-password
  271. -ep --encrypt-password
  272. -f --file
  273. -fae --fail-at-end
  274. -ff --fail-fast
  275. -fn --fail-never
  276. -gs --global-settings
  277. -gt --global-toolchains
  278. -h --help
  279. -l --log-file
  280. -llr --legacy-local-repository
  281. -N --non-recursive
  282. -npr --no-plugin-registry
  283. -npu --no-plugin-updates
  284. -nsu --no-snapshot-updates
  285. -o --offline
  286. -P --activate-profiles
  287. -pl --projects
  288. -q --quiet
  289. -rf --resume-from
  290. -s --settings
  291. -t --toolchains
  292. -T --threads
  293. -U --update-snapshots
  294. -up --update-plugins
  295. -v --version
  296. -V --show-version
  297. -X --debug
  298. cli:execute cli:execute-phase
  299. archetype:generate generate-sources
  300. cobertura:cobertura
  301. -Dtest=$(if [ -d ./src/test/java ] ; then find ./src/test/java -type f -name '*.java' | grep -v svn | sed 's?.*/\([^/]*\)\..*?-Dtest=\1?' ; fi)
  302. -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)
  303. $profiles
  304. $modules
  305. )
  306. }
  307. compctl -K listMavenCompletions mvn mvnw
  308. compctl -K listMavenCompletions mvn-color
  309. compctl -K listMavenCompletions mvn-or-mvnw