Podpowiadanie dla mavena w bashu
Jacek opisał w swoim blogu mechanizm uzupełniania w powłoce bash. Ja nie mam żadnych obiekcji przed radosnym uzupełnieniem jego tekstu o ten oto mały skrypcik mavena:
Listing 1. (Prawie)Pełny spis argumentów dla mavena
_mvn(){
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="-Dversion= -DarchetypeArtifactId= -DartifactId= -DgroupId= -q --quiet -C --strict-checksum -c --lax-checksums -P --activate-profiles -ff --fail-fast -fae --fail-at-end -B --batch-mode -fn --fail-never -up --update-plugins -N --non-recursive -npr --no-plugin-registr -U --update-snapshots -cpu --check-plugin-updates -npu --no-plugin-updates -D --define -X --debug -e --errors -f --file -h --help -o --offline -r --reactor -s --settings -v --version -? clean clean:clean compiler:compile compiler:testCompile compile deploy:deploy deploy:deploy-file deploy install:install install:install-file install resources:resources resources:testResources site:deploy site:attach-descriptor site:site site:run site:stage-deploy site:stage site surefire:test test verifier:verify verify ear:ear ear:generate-application-xml ejb:ejb jar:jar jar:test-jar jar:sign jar:sign-verify rar:rar war:war war:exploded war:inplace changelog:changelog changelog:dev-activity changelog:file-activity changes:announcement-mail changes:announcement-generate changes:changes-report changes:jira-report checkstyle:checkstyle checkstyle:check clover:aggregate clover:check clover:instrumentInternal clover:instrument clover:log clover:clover clover:save-history doap:generate docck:check javadoc:javadoc javadoc:test-javadoc javadoc:jar jxr:jxr jxr:test-jxr pmd:pmd pmd:cpd pmd:check pmd:cpd-check project-info-reports:cim project-info-reports:dependencies project-info-reports:dependency-convergence project-info-reports:issue-tracking project-info-reports:license project-info-reports:mailing-list project-info-reports:index project-info-reports:summary project-info-reports:scm project-info-reports:project-team surefire-report:report surefire-report:report-only ant:ant ant:clean ant antrun:run archetype:create archetype:create-from-project -DarchetypeArtifactId=maven-archetype-archetype -DarchetypeArtifactId=maven-archetype-j2ee-simple -DarchetypeArtifactId=maven-archetype-mojo -DarchetypeArtifactId=maven-archetype-portlet -DarchetypeArtifactId=maven-archetype-profiles -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeArtifactId=maven-archetype-simple -DarchetypeArtifactId=maven-archetype-site -DarchetypeArtifactId=maven-archetype-site-simple -DarchetypeArtifactId=maven-archetype-webapp assembly:assembly assembly:attached assembly:directory assembly:directory-inline assembly:unpack assembly:single assembly:directory-single dependency:copy dependency:copy-dependencies dependency:unpack dependency:unpack-dependencies dependency:resolve dependency:list dependency:sources dependency:resolve-plugins dependency:list dependency:go-offline dependency:purge-local-repository dependency:build-classpath dependency:analyze dependency:analyze-only dependency:analyze-dep-mgt dependency:tree enforcer:enforce enforcer:enforce-once enforcer:display-info gpg:sign gpg:sign-and-deploy-file help:active-profiles help:describe help:effective-pom help:effective-settings invoker:run one:convert one:deploy-maven-one-repository one:install-maven-one-repository one:maven-one-plugin plugin:descriptor plugin:report plugin:updateRegistry plugin:xdoc plugin:addPluginArtifactMetadata release:clean release:perform release:prepare release:rollback release:branch remote-resources:bundle remote-resources:process scm:add scm:changelog scm:checkin scm:checkout scm:diff scm:edit scm:status scm:tag scm:unedit scm:update scm:validate source:aggregate source:jar source:test-jar eclipse:configure-workspace eclipse:eclipse eclipse:clean eclipse:m2eclipse eclipse:to-maven eclipse:install-plugins eclipse:make-artifacts eclipse:myeclipse eclipse:myeclipse-clean eclipse:rad eclipse:rad-clean idea:idea idea:project idea:module idea:workspace idea:clean build-helper:add-source build-helper:add-test-source build-helper:attach-artifact castor:generate jdepend:generate native:initialize native:compile native:link native:javah native:ranlib native:resource-compile native:compile-message sql:execute taglist:taglist cargo:start cargo:stop cargo:deployer-deploy cargo:deploy cargo:deployer-undeploy cargo:undeploy cargo:deployer-start cargo:deployer-stop cargo:deployer-redeploy cargo:uberwar cargo:install jaxme:jaxme jetty:run jetty:run-war jetty:run-exploded"
if [[ ${cur} == * ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi}
W spisie uwzględnione zostały wszystkie pluginy wymienione na stronie ze spisem pluginów mavena. Warunkiem koniecznym było posiadanie wpisów w sekcji goals. Dodatkowo dodane zostały najpopularniejsze flagi dla -D. Razem jest tu 248 różnych opcji.
//edit:
Na stronach mavena jest też taki skrypt:
Listing 2. Wersja ze strony mavena:
#!/bin/bash
_m2_make_goals()
{
plugin=$1
mojos=$2
for mojo in $mojos
do
export goals="$goals $plugin:$mojo"
done
}
_m2_complete()
{
local cur goals
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
goals='clean compile test install package deploy site'
goals=$goals _m2_make_goals "eclipse" "eclipse"
goals=$goals _m2_make_goals "idea" "idea"
goals=$goals _m2_make_goals "assembly" "assembly"
goals=$goals _m2_make_goals "plexus" "app bundle-application bundle-runtime descriptor runtime service"
cur=`echo $cur | sed 's/\\\\//g'`
COMPREPLY=($(compgen -W "${goals}" ${cur} | sed 's/\\\\//g') )
}
complete -F _m2_complete -o filenames mvn
Kod jest dostępny na licencji MIT. Jednak niektóre rozwiązania mogą być objęte inną licencją. W takim przypadku jest, to zaznaczone. Artykuły są dostępne na licencji CC-BY.
Jeżeli spodobał ci się ten wpis, to podziel się nim z innymi lub wesprzyj autora.