Guest User

Untitled

a guest
Sep 25th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.32 KB | None | 0 0
  1. # Programmable completion for the Maven mvn command under bash. Source
  2. # this file (or on some systems add it to ~/.bash_completion and start a new
  3. # shell) and bash's completion mechanism will know all about mvn's options!
  4. #
  5. # Copyright (C) 2009, Ludovic Claude <ludovic.claude@laposte.net>
  6. # Base on git completion script, Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
  7. # Distributed under the GNU General Public License, version 2.0.
  8.  
  9. # Customization: you can always edit this file (as root) and add or remove plugins and options in the lists defined below.
  10. # If you have some interesting changes, please send patches to ludovic.claude@laposte.net
  11. # Alternatively, you can create a file called bash_completion in your ~/.m2 directory.
  12. # This file can override any of the variables defined below (__mvnopts, __mvnoptsWithArg __mvnparams, __mvnpackaging,
  13. # __mvnclassifiers, __mvndefault_phases, __mvnclean_phases, __mvnsite_phases, __mvncore_plugins, __mvnpackaging_plugins,
  14. # __mvnreporting_plugins, __mvntools_plugins, __mvnide_plugins, __mvnother_plugins, __mvncustom_plugins)
  15. # __mvncustom_plugins is the best variable to use to add new plugins and goals
  16. #
  17.  
  18. __mvnopts="--also-make --also-make-dependents --file --debug --batch-mode --lax-checksums --strict-checksums --check-plugin-updates --define
  19. --errors --encrypt-master-password --encrypt-password --fail-at-end --fail-fast --fail-never --help --non-recursive --no-plugin-registry
  20. --no-plugin-updates --offline --activate-profiles --projects --quiet --reactor --resume-from --settings --global-settings --update-snapshots
  21. --update-plugins --version --show-version"
  22.  
  23. __mvnoptsWithArg="--file|--define|--encrypt-master-password|--encrypt-password|--resume-from|--settings|--global-settings|--activate-profiles|--projects"
  24.  
  25. __mvnparams="-Dmaven.test.skip=true -Dsurefire.useFile=false -Dmaven.surefire.debug -Xdebug -Xnoagent -Djava.compiler=NONE
  26. -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=y -Dverbose -Dmaven.test.failure.ignore=true"
  27.  
  28. __mvnpackaging="pom jar maven-plugin php ejb war ear rar par"
  29. __mvnclassifiers="sources test-jar"
  30. __mvnscopes="compile test runtime system"
  31.  
  32. # phases for the default lifecycle
  33. __mvndefault_phases="validate
  34. initialize
  35. generate-sources
  36. process-sources
  37. generate-resources
  38. process-resources
  39. compile
  40. process-classes
  41. generate-test-sources
  42. process-test-sources
  43. generate-test-resources
  44. process-test-resources
  45. test-compile
  46. process-test-classes
  47. test
  48. package
  49. pre-integration-test
  50. integration-test
  51. post-integration-test
  52. verify
  53. install
  54. deploy"
  55.  
  56. # phases for the clean lifecycle
  57. __mvnclean_phases="pre-clean
  58. clean
  59. post-clean"
  60.  
  61. # phases for the site lifecycle
  62. __mvnsite_phases="pre-site
  63. site
  64. post-site
  65. site-deploy"
  66.  
  67. # core plugin targets
  68. __mvncore_plugins="clean:clean
  69. clean:help
  70. compiler:compile
  71. compiler:testCompile
  72. compiler:help
  73. deploy:deploy
  74. deploy:deploy-file
  75. deploy:help
  76. install:install
  77. install:install-file
  78. install:help
  79. resources:resources
  80. resources:testResources
  81. resources:copy-resources
  82. resources:help
  83. site:site
  84. site:deploy
  85. site:run
  86. site:stage
  87. site:stage-deploy
  88. site:attach-descriptor
  89. site:jar
  90. site:help
  91. surefire:test
  92. surefire:help
  93. verifier:verify
  94. verifier:help"
  95.  
  96. # packaging plugin targets
  97. __mvnpackaging_plugins="ear:ear
  98. ear:generate-application-xml
  99. ear:help
  100. jar:jar
  101. jar:test-jar
  102. jar:sign
  103. jar:sign-verify
  104. jar:help
  105. rar:rar
  106. rar:help
  107. war:war
  108. war:exploded
  109. war:inplace
  110. war:manifest
  111. war:help
  112. shade:shade
  113. shade:help"
  114.  
  115. # reporting plugin targets
  116. __mvnreporting_plugins="changelog:changelog
  117. changelog:dev-activity
  118. changelog:file-activity
  119. changelog:help
  120. changes:announcement-mail
  121. changes:announcement-generate
  122. changes:changes-report
  123. changes:jira-report
  124. changes:changes-validate
  125. changes:help
  126. checkstyle:checkstyle
  127. checkstyle:check
  128. checkstyle:help
  129. doap:generate
  130. doap:help
  131. docck:check
  132. docck:help
  133. javadoc:javadoc
  134. javadoc:test-javadoc
  135. javadoc:aggregate
  136. javadoc:test-aggregate
  137. javadoc:jar
  138. javadoc:test-jar
  139. javadoc:help
  140. jxr:jxr
  141. jxr:test-jxr
  142. jxr:help
  143. pmd:pmd
  144. pmd:cpd
  145. pmd:check
  146. pmd:cpd-check
  147. pmd:help
  148. project-info-reports:cim
  149. project-info-reports:dependencies
  150. project-info-reports:dependency-convergence
  151. project-info-reports:dependency-management
  152. project-info-reports:index
  153. project-info-reports:issue-tracking
  154. project-info-reports:license
  155. project-info-reports:mailing-list
  156. project-info-reports:plugin-management
  157. project-info-reports:project-team
  158. project-info-reports:scm
  159. project-info-reports:summary
  160. project-info-reports:help
  161. surefire-report:report
  162. surefire-report:report-only
  163. surefire-report:help"
  164.  
  165. # tools plugin targets
  166. __mvntools_plugins="ant:ant
  167. ant:clean
  168. ant:help
  169. antrun:run
  170. antrun:help
  171. archetype:create
  172. archetype:generate
  173. archetype:create-from-project
  174. archetype:crawl
  175. archetype:help
  176. assembly:assembly
  177. assembly:directory
  178. assembly:directory-single
  179. assembly:single
  180. assembly:help
  181. dependency:copy
  182. dependency:copy-dependencies
  183. dependency:unpack
  184. dependency:unpack-dependencies
  185. dependency:resolve
  186. dependency:list
  187. dependency:sources
  188. dependency:resolve-plugins
  189. dependency:go-offline
  190. dependency:purge-local-repository
  191. dependency:build-classpath
  192. dependency:analyze
  193. dependency:analyze-dep-mgt
  194. dependency:tree
  195. dependency:help
  196. enforcer:enforce
  197. enforcer:display-info
  198. enforcer:help
  199. gpg:sign
  200. gpg:sign-and-deploy-file
  201. gpg:help
  202. help:active-profiles
  203. help:all-profiles
  204. help:describe
  205. help:effective-pom
  206. help:effective-settings
  207. help:evaluate
  208. help:expressions
  209. help:system
  210. invoker:install
  211. invoker:run
  212. invoker:help
  213. one:convert
  214. one:deploy-maven-one-repository
  215. one:install-maven-one-repository
  216. one:maven-one-plugin
  217. one:help
  218. patch:apply
  219. patch:help
  220. pdf:pdf
  221. pdf:help
  222. plugin:descriptor
  223. plugin:report
  224. plugin:updateRegistry
  225. plugin:xdoc
  226. plugin:addPluginArtifactMetadata
  227. plugin:helpmojo
  228. plugin:help
  229. release:clean
  230. release:prepare
  231. release:rollback
  232. release:perform
  233. release:stage
  234. release:branch
  235. release:help
  236. reactor:resume
  237. reactor:make
  238. reactor:make-dependents
  239. reactor:make-scm-changes
  240. reactor:help
  241. remote-resources:bundle
  242. remote-resources:process
  243. remote-resources:help
  244. repository:bundle-create
  245. repository:bundle-pack
  246. repository:help
  247. scm:branch
  248. scm:validate
  249. scm:add
  250. scm:unedit
  251. scm:export
  252. scm:bootstrap
  253. scm:changelog
  254. scm:list
  255. scm:checkin
  256. scm:checkout
  257. scm:status
  258. scm:update
  259. scm:diff
  260. scm:update-subprojects
  261. scm:edit
  262. scm:tag
  263. scm:help
  264. source:aggregate
  265. source:jar
  266. source:test-jar
  267. source:jar-no-fork
  268. source:test-jar-no-fork
  269. source:help
  270. stage:copy
  271. stage:help"
  272.  
  273. # IDE plugin targets
  274. __mvnide_plugins="eclipse:clean
  275. eclipse:configure-workspace
  276. eclipse:eclipse
  277. eclipse:help
  278. eclipse:install-plugins
  279. eclipse:m2eclipse
  280. eclipse:make-artifacts
  281. eclipse:myeclipse
  282. eclipse:myeclipse-clean
  283. eclipse:rad
  284. eclipse:rad-clean
  285. eclipse:remove-cache
  286. eclipse:to-maven
  287. idea:clean
  288. idea:help
  289. idea:idea
  290. idea:module
  291. idea:project
  292. idea:workspace"
  293.  
  294. __mvnother_plugins=""
  295.  
  296. __mvncustom_plugins="magento:artifact magento:archetype magento:create-db magento:drop-db magento:dump-db magento:import-db magento:info magento:help magento:setup magento-setupTest magento:snippet magento:symlink"
  297.  
  298. ### End of customizable area
  299.  
  300. if [ -e ~/.m2/bash_completion ]; then
  301. source ~/.m2/bash_completion
  302. fi
  303.  
  304. __mvnphases="${__mvndefault_phases} ${__mvnclean_phases} ${__mvnsite_phases}"
  305.  
  306. __mvnall_plugin_and_goals="${__mvncore_plugins} ${__mvnpackaging_plugins} ${__mvnreporting_plugins} ${__mvntools_plugins}
  307. ${__mvnide_plugins} ${__mvnother_plugins} ${__mvncustom_plugins}"
  308.  
  309. __mvnplugins=$(echo ${__mvnall_plugin_and_goals} | sed -re 's/:[^ \t]+/:\n/g' | sort -u | sed 's/[\s\n]//g')
  310.  
  311. __mvncomp_1 ()
  312. {
  313. local c IFS=' '$'\t'$'\n'
  314. for c in $1; do
  315. case "$c$2" in
  316. --*=*) printf %s$'\n' "$c$2" ;;
  317. *.) printf %s$'\n' "$c$2" ;;
  318. *) printf %s$'\n' "$c$2 " ;;
  319. esac
  320. done
  321. }
  322.  
  323. __mvncomp ()
  324. {
  325. local genOpt=
  326. if [ "$1" == "-nospace" ]; then
  327. genOpt="true"
  328. shift
  329. fi
  330. local cur="${COMP_WORDS[COMP_CWORD]}"
  331. if [ $# -gt 2 ]; then
  332. cur="$3"
  333. fi
  334. case "$cur" in
  335. -*=)
  336. COMPREPLY=()
  337. ;;
  338. *)
  339. local IFS=$'\n'
  340. COMPREPLY=($(compgen -P "$2" \
  341. -W "$(__mvncomp_1 "$1" "$4")" \
  342. -- "$cur"))
  343. ;;
  344. esac
  345. }
  346.  
  347. __mvnlist_projects ()
  348. {
  349. local poms=$(find . -name pom.xml -print)
  350. echo $poms | while read -d ' ' POM; do
  351. local DIR=$(dirname "$POM")
  352. if [[ "$DIR" != "." ]]; then
  353. echo "${DIR#./}"
  354. fi
  355. done
  356. }
  357.  
  358. __mvnlist_goals ()
  359. {
  360. local plugin=$1
  361. local pfx=""
  362. if [[ "$2" ]]; then
  363. pfx=$2
  364. fi
  365. echo ${__mvnall_plugin_and_goals} | tr ' ' '\n' | grep "$plugin" | sed "s/.*:/${pfx}/g"
  366. }
  367.  
  368. __mvnlist_poms ()
  369. {
  370. for x in `find -type f -name pom.xml -or -name *.pom` ; do echo ${x#./} ; done
  371. }
  372.  
  373. __mvnlist_jars ()
  374. {
  375. for x in `find -type f -name *.jar` ; do echo ${x#./} ; done
  376. }
  377.  
  378. __mvnlist_prefix ()
  379. {
  380. local pfx=$1 IFS=' '$'\t'$'\n'
  381. shift
  382. local list=$@
  383. for c in $list; do
  384. echo "$pfx$c"
  385. done
  386. }
  387.  
  388. __mvnprefix_equals ()
  389. {
  390. local cur=$1
  391. local pfx=""
  392. case "$COMP_WORDBREAKS" in
  393. *=*) : great ;;
  394. *) pfx="${cur%%=*}=" ;;
  395. esac
  396. echo $pfx
  397. }
  398.  
  399. __mvnprefix_colon ()
  400. {
  401. local cur=$1
  402. local pfx=""
  403. case "$COMP_WORDBREAKS" in
  404. *:*) : great ;;
  405. *) pfx="${cur%%:*}:" ;;
  406. esac
  407. echo $pfx
  408. }
  409.  
  410. __mvnprefix_comma ()
  411. {
  412. local cur=$1
  413. local pfx=""
  414. case "$COMP_WORDBREAKS" in
  415. *,*) : great ;;
  416. *) pfx="${cur%%,*}," ;;
  417. esac
  418. echo $pfx
  419. }
  420.  
  421. __mvnplugin_help ()
  422. {
  423. local plugin=$1
  424. local cur="${COMP_WORDS[COMP_CWORD]}"
  425. cur="${cur#-D}"
  426. case "${cur}" in
  427. goal=*)
  428. __mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  429. ;;
  430. *)
  431. __mvncomp "detail lineLength= indentSize= $(__mvnlist_goals $plugin 'goal=')" "-D" "${cur}"
  432. ;;
  433. esac
  434. }
  435.  
  436. __mvnhelp_describe ()
  437. {
  438. local cur="${COMP_WORDS[COMP_CWORD]}"
  439. cur="${cur#-D}"
  440. case "${cur}" in
  441. cmd=*:*)
  442. local plugin="${cur#*=}"
  443. plugin="${plugin%%:*}:"
  444. __mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cur)" "${cur#*:}"
  445. ;;
  446. cmd=*)
  447. __mvncomp "${__mvnphases} ${__mvnall_plugin_and_goals}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  448. ;;
  449. plugin=*)
  450. __mvncomp "org.apache.maven.plugins:maven-" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  451. ;;
  452. groupId=*)
  453. __mvncomp "org.apache.maven.plugins" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  454. ;;
  455. artifactId=*)
  456. __mvncomp "" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  457. ;;
  458. *)
  459. # present several cmd= options to block full completion and insertion of a space
  460. __mvncomp "detail cmd=press cmd=tab plugin= groupId= artifactId=" "-D" "${cur}"
  461. ;;
  462. esac
  463. }
  464.  
  465. __mvndeploy_deploy ()
  466. {
  467. local cur="${COMP_WORDS[COMP_CWORD]}"
  468. cur="${cur#-D}"
  469. __mvncomp "altDeploymentRepository= skip=true updateReleaseInfo=true" "-D" "${cur}"
  470. }
  471.  
  472. __mvndeploy_deploy_file ()
  473. {
  474. local cur="${COMP_WORDS[COMP_CWORD]}"
  475. cur="${cur#-D}"
  476. case "${cur}" in
  477. file=*)
  478. COMPREPLY=( $( compgen -f -P "$(__mvnprefix_equals $cur)" -- "${cur#*=}" ) )
  479. ;;
  480. pomFile=*)
  481. __mvncomp "$(__mvnlist_poms)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  482. ;;
  483. packaging=*)
  484. __mvncomp "${__mvnpackaging}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  485. ;;
  486. *)
  487. local options="artifactId= classifier= description= file=press file=tab generatePom=true groupId= pomFile=press pomFile=tab repositoryId=
  488. repositoryLayout=legacy uniqueVersion=false url= version="
  489. options="$options $(__mvnlist_prefix 'packaging=' ${__mvnpackaging} )"
  490. __mvncomp "$options" "-D" "${cur}"
  491. ;;
  492. esac
  493. }
  494.  
  495. __mvninstall_install_file ()
  496. {
  497. local cur="${COMP_WORDS[COMP_CWORD]}"
  498. cur="${cur#-D}"
  499. case "${cur}" in
  500. file=*)
  501. COMPREPLY=( $( compgen -f -P "$(__mvnprefix_equals $cur)" -- "${cur#*=}" ) )
  502. ;;
  503. pomFile=*)
  504. __mvncomp "$(__mvnlist_poms)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  505. ;;
  506. sources=*)
  507. __mvncomp "$(__mvnlist_jars)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  508. ;;
  509. javadoc=*)
  510. __mvncomp "$(__mvnlist_jars)" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  511. ;;
  512. packaging=*)
  513. __mvncomp "${__mvnpackaging}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  514. ;;
  515. *)
  516. local options="artifactId= classifier= file=press file=tab generatePom=true groupId= pomFile=press pomFile=tab
  517. createChecksum=true url= version= sources=press sources=tab javadoc=press javadoc=tab"
  518. options="$options $(__mvnlist_prefix 'packaging=' ${__mvnpackaging} )"
  519. __mvncomp "$options" "-D" "${cur}"
  520. ;;
  521. esac
  522. }
  523.  
  524. __mvnexec_java ()
  525. {
  526. local cur="${COMP_WORDS[COMP_CWORD]}"
  527. if [[ "${cur}" == "=" ]]; then
  528. cur="${COMP_WORDS[COMP_CWORD-1]}="
  529. fi
  530. cur="${cur#-Dexec.}"
  531. case "${cur}" in
  532. classpathScope=*)
  533. __mvncomp "${__mvnscopes}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  534. ;;
  535. *)
  536. local options="mainClass= args= arguments= includeProjectDependencies=false includePluginDependencies=true
  537. classpathScope=press classpathScope=tab
  538. cleanupDaemonThreads=false daemonThreadJoinTimeout= stopUnresponsiveDaemonThreads="
  539. __mvncomp "$options" "-Dexec." "${cur}"
  540. ;;
  541. esac
  542. }
  543.  
  544. __mvnarchetype_generate ()
  545. {
  546. local cur="${COMP_WORDS[COMP_CWORD]}"
  547. cur="${cur#-D}"
  548. case "${cur}" in
  549. basedir=*)
  550. COMPREPLY=( $( compgen -d -P "$(__mvnprefix_equals $cur)" -- "${cur#*=}" ) )
  551. ;;
  552. *)
  553. local options="archetypeArtifactId= archetypeCatalog= archetypeGroupId= archetypeRepository= archetypeVersion= basedir=press basedir=tab goals= interactiveMode="
  554. __mvncomp "$options" "-D" "${cur}"
  555. ;;
  556. esac
  557. }
  558.  
  559. __mvndependency_x_dependencies ()
  560. {
  561. local cur="${COMP_WORDS[COMP_CWORD]}"
  562. cur="${cur#-D}"
  563. case "${cur}" in
  564. classifier=*)
  565. __mvncomp "${__mvnclassifiers}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  566. ;;
  567. *)
  568. __mvncomp "$(__mvnlist_prefix 'classifier=' ${__mvnclassifiers})" "-D" "${cur}"
  569. ;;
  570. esac
  571. }
  572.  
  573. __mvndependency_resolve ()
  574. {
  575. local cur="${COMP_WORDS[COMP_CWORD]}"
  576. cur="${cur#-D}"
  577. case "${cur}" in
  578. classifier=*)
  579. __mvncomp "${__mvnclassifiers}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  580. ;;
  581. *)
  582. __mvncomp "$(__mvnlist_prefix 'classifier=' ${__mvnclassifiers}) excludeArtifactIds= excludeClassifiers= excludeGroupIds=
  583. excludeScope= excludeTransitive=true excludeTypes= includeArtifactIds= includeClassifiers= includeGroupIds= includeScope=
  584. includeTypes= markersDirectory= outputAbsoluteArtifactFilename= outputFile= outputScope=false overWriteIfNewer=false
  585. overWriteReleases=true overWriteSnapshots=true silent=true type="
  586. "-D" "${cur}"
  587. ;;
  588. esac
  589. }
  590.  
  591. __mvndependency_purge_local_repository ()
  592. {
  593. local fuzziness="file version artifactId groupId"
  594. local cur="${COMP_WORDS[COMP_CWORD]}"
  595. cur="${cur#-D}"
  596. case "${cur}" in
  597. resolutionFuzziness=*)
  598. __mvncomp "${fuzziness}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  599. ;;
  600. *)
  601. __mvncomp "actTransitively=false exclude= reResolve=false verbose=true
  602. $(__mvnlist_prefix 'resolutionFuzziness=' ${fuzziness})"
  603. "-D" "${cur}"
  604. ;;
  605. esac
  606. }
  607.  
  608. __mvndependency_analyze ()
  609. {
  610. local cur="${COMP_WORDS[COMP_CWORD]}"
  611. cur="${cur#-D}"
  612. __mvncomp "ignoreNonCompile=true outputXML=true scriptableFlag= scriptableOutput=true verbose=true" "-D" "${cur}"
  613. }
  614.  
  615. __mvndependency_analyze_dep_mgt ()
  616. {
  617. local cur="${COMP_WORDS[COMP_CWORD]}"
  618. cur="${cur#-D}"
  619. __mvncomp "ignoreDirect=false" "-D" "${cur}"
  620. }
  621.  
  622. __mvndependency_tree ()
  623. {
  624. local tokens="whitespace standard extended"
  625. local cur="${COMP_WORDS[COMP_CWORD]}"
  626. cur="${cur#-D}"
  627. case "${cur}" in
  628. tokens=*)
  629. __mvncomp "${tokens}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  630. ;;
  631. *)
  632. __mvncomp "excludes= includes= outputFile= scope= verbose=true
  633. $(__mvnlist_prefix 'tokens=' ${tokens})"
  634. "-D" "${cur}"
  635. ;;
  636. esac
  637. }
  638.  
  639. __mvnrelease_prepare ()
  640. {
  641. local cur="${COMP_WORDS[COMP_CWORD]}"
  642. cur="${cur#-D}"
  643. __mvncomp "username= dryRun=true" "-D" "${cur}"
  644. }
  645.  
  646. __mvnscm_checkin ()
  647. {
  648. local versionType="branch tag revision"
  649. local cur="${COMP_WORDS[COMP_CWORD]}"
  650. cur="${cur#-D}"
  651. case "${cur}" in
  652. scmVersionType=*)
  653. __mvncomp "${versionType}" "$(__mvnprefix_equals $cur)" "${cur#*=}"
  654. ;;
  655. *)
  656. __mvncomp "username= message= passphrase= password= scmVersion= $(__mvnlist_prefix 'scmVersionType=' ${versionType})" "-D" "${cur}"
  657. ;;
  658. esac
  659. }
  660.  
  661. _mvn ()
  662. {
  663. local i prev c=1 cmd option optionArg=0 cmdcomplete=0
  664. local cur="${COMP_WORDS[COMP_CWORD]}"
  665. COMPREPLY=()
  666.  
  667. #echo " cur $cur"
  668.  
  669. # discover the options and the command
  670. while [ $c -le $COMP_CWORD ]; do
  671. prev=$i
  672. i="${COMP_WORDS[c]}"
  673. c=$((++c))
  674. optionArg=0
  675. # skip option argument
  676. if [[ $prev == @(${__mvnoptsWithArg}) ]]; then
  677. optionArg=1
  678. continue;
  679. fi
  680.  
  681. #echo "c $c i '$i'"
  682.  
  683. if [[ $cmdcomplete == -3 ]]; then
  684. cmdcomplete=1 # complete command
  685. break;
  686. fi
  687.  
  688. if [[ "$i" == "" ]]; then
  689. if [[ $cmd ]]; then
  690. cmdcomplete=1 # complete command
  691. break;
  692. fi
  693. continue
  694. fi
  695.  
  696. if [[ "$i" == ":" ]]; then
  697. if [[ $cmd ]]; then
  698. cmdcomplete=$((cmdcomplete-1))
  699. cmd="${cmd}:"
  700. fi
  701. continue
  702. fi
  703.  
  704. case "$i" in
  705. --version|--help) return ;;
  706. -*) option="$i" ;;
  707. *) if [[ ! $cmd ]]; then
  708. # incomplete command
  709. cmdcomplete=$((cmdcomplete-1))
  710. cmd="$i"
  711. local next=$c
  712. if [[ $next -lt $COMP_CWORD ]]; then
  713. #echo "next ${COMP_WORDS[next]}"
  714. if [[ "${COMP_WORDS[next]}" != ":" ]]; then
  715. break
  716. fi
  717. fi
  718. else
  719. cmdcomplete=$((cmdcomplete-1))
  720. cmd="$cmd$i"
  721. fi
  722. ;;
  723. esac
  724. done
  725.  
  726. #echo "cmd $cmd cmdcomplete $cmdcomplete"
  727.  
  728. if [[ ! $cmd && $option && ($optionArg == 0) ]]; then
  729. case "$option" in
  730. --file)
  731. __mvncomp "$(__mvnlist_poms)"
  732. return
  733. ;;
  734. --define)
  735. __mvncomp "maven.test.skip=true"
  736. return
  737. ;;
  738. --resume-from)
  739. __mvncomp "$(__mvnlist_projects)"
  740. return
  741. ;;
  742. --projects)
  743. case "${cur}" in
  744. *,*)
  745. __mvncomp "$(__mvnlist_projects)" "$(__mvnprefix_comma $cur)" "${cur#*,}"
  746. ;;
  747. *) __mvncomp "$(__mvnlist_projects)"
  748. ;;
  749. esac
  750. return
  751. ;;
  752. --settings|--global-settings)
  753. COMPREPLY=( $( compgen -f -- $cur ) )
  754. return
  755. ;;
  756. --*)
  757. COMPREPLY=()
  758. ;;
  759. esac
  760. fi
  761.  
  762. if [ $cmdcomplete -lt 0 ]; then
  763. #echo "incomplete cmd $cmd"
  764. case "${cmd}" in
  765. *:)
  766. local plugin="${cmd%%:}:"
  767. #echo "plugin $plugin"
  768. __mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cmd)" ""
  769. ;;
  770. *:*)
  771. local plugin="${cmd%%:*}:"
  772. #echo "plugin $plugin"
  773. __mvncomp "$(__mvnlist_goals $plugin)" "$(__mvnprefix_colon $cmd)" "${cmd#*:}"
  774. ;;
  775. *) __mvncomp "${__mvnphases} ${__mvnall_plugin_and_goals}" ;;
  776. esac
  777. return
  778. fi
  779.  
  780. if [ -z "$cmd" ]; then
  781. #echo "empty cmd cur $cur"
  782. case "${cur}" in
  783. -D*=*) COMPREPLY=() ;;
  784. -*) __mvncomp "${__mvnopts} ${__mvnparams}" ;;
  785. --*) __mvncomp "${__mvnopts}" ;;
  786. *) __mvncomp "${__mvnphases} ${__mvnall_plugin_and_goals}" ;;
  787. esac
  788. return
  789. fi
  790.  
  791. #echo "cmd $cmd"
  792.  
  793. case "$cmd" in
  794. *:help)
  795. local plugin="${cmd%%:*}:"
  796. __mvnplugin_help $plugin
  797. ;;
  798. help:describe) __mvnhelp_describe ;;
  799. deploy:deploy) __mvndeploy_deploy ;;
  800. deploy:deploy-file) __mvndeploy_deploy_file ;;
  801. archetype:generate) __mvnarchetype_generate ;;
  802. dependency:copy-dependencies) __mvndependency_x_dependencies ;;
  803. dependency:unpack-dependencies) __mvndependency_x_dependencies ;;
  804. dependency:resolve) __mvndependency_resolve ;;
  805. dependency:resolve-plugins) __mvndependency_resolve ;;
  806. dependency:source) __mvndependency_resolve ;;
  807. dependency:go-offline) __mvndependency_resolve ;;
  808. dependency:purge-local-repository) __mvndependency_purge_local_repository ;;
  809. dependency:analyze) __mvndependency_analyze ;;
  810. dependency:analyze-dep-mgt) __mvndependency_analyze_dep_mgt ;;
  811. exec:java) __mvnexec_java ;;
  812. install:install-file) __mvninstall_install_file ;;
  813. release:prepare) __mvnrelease_prepare ;;
  814. scm:checkin) __mvnscm_checkin ;;
  815. *)
  816. ;;
  817. esac
  818. }
  819.  
  820. complete -o default -o nospace -F _mvn mvn mvnDebug
Add Comment
Please, Sign In to add comment