Mvn: Some cleaning

This commit is contained in:
Julien Nicoulaud 2011-08-05 12:18:59 +02:00
parent 30515972f2
commit 3e0ecc2846
1 changed files with 59 additions and 45 deletions

96
_mvn
View File

@ -155,7 +155,7 @@ _mvn_phases() {
'site:generates the projects site documentation'
'site-deploy:deploys the generated site documentation to the specified web server'
)
if zstyle -t ":completion:${curcontext}:" show-advanced-phases || [[ $#PREFIX -gt 0 ]]; then
if [[ $#PREFIX -gt 0 ]] || zstyle -t ":completion:${curcontext}:" show-advanced-phases; then
phases+=(
'pre-clean:executes processes needed prior to the actual project cleaning'
'post-clean:executes processes needed to finalize the project cleaning'
@ -199,7 +199,8 @@ _mvn_plugins() {
local plugins
# TODO Add the plugins for which we have a cache
zstyle -a ":completion:${curcontext}:" plugins plugins
[[ $#plugins -gt 0 ]] || plugins=(
if [[ $#plugins -eq 0 ]]; then
plugins=(
'assembly:create archives of your projects sources, classes, dependencies etc. from flexible assembly descriptors'
'release:release a project with Maven, saving a lot of repetitive, manual work'
'help:provides goals aimed at helping to make sense out of the build environment.'
@ -210,6 +211,7 @@ _mvn_plugins() {
'site:generate a site for the project'
'install:copies the project artifacts to the local repository.'
)
fi
_describe -t 'plugin' "plugin" plugins -S ':'
}
@ -357,7 +359,56 @@ _mvn_projects() {
_mvn_properties() {
local ret=1
if compset -P '*='; then
local property=${${IPREFIX%=}#-D}
_wanted property-value expl 'property value' _mvn_property_values ${${IPREFIX%=}#-D} && ret=0
else
_wanted property-name expl 'property name' _mvn_property_names && ret=0
fi
return ret
}
(( $+functions[_mvn_property_names] )) ||
_mvn_property_names() {
local alternatives; alternatives=(
'common property names:common property:_mvn_common_property_names'
)
for plugin_colon_goal in ${(M)words:#*:*}; do # FIXME pretty sure this matches more than just plugin:goals
alternatives+=("plugin property names:plugin property name:_mvn_plugin_goal_property_names '${plugin_colon_goal%:*}' '${plugin_colon_goal#*:}'")
done
_alternative "${alternatives[@]}"
}
(( $+functions[_mvn_common_property_names] )) ||
_mvn_common_property_names() {
local properties; properties=(
'skipTests:skip tests execution'
'maven.test.skip:skip tests compilation and execution'
'gpg.passphrase:gpg passphrase'
)
_describe -t 'common-properties-names' "Common property name" properties -qS=
}
(( $+functions[_mvn_plugin_goal_property_names] )) ||
_mvn_plugin_goal_property_names() {
local plugin="${(P)$(($# -1))}" goal="${(P)${#}}" update_policy ret=1
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_plugin_goal_property_names_caching_policy
unset properties
if ( [[ ${+properties} -eq 0 ]] || _cache_invalid "mvn/plugins/${plugin}/${goal}" ) && ! _retrieve_cache "mvn/plugins/${plugin}/${goal}"; then
properties=(${(M)${(ps:,,,:)${${${${(pj: :)${${${(f)${"$(_call_program properties $words[1] -N org.apache.maven.plugins:maven-help-plugin:2.1.1:describe -Dplugin=$plugin -Dgoal=$goal -Ddetail)"#*Available parameters:}%%\[INFO\]*}//# [a-z]*/,,,}##*Expression: \$\{}}//\}[[:space:]]##/:}//[[:space:]]##/ }//[[:space:]]#,,,[[:space:]]#/,,,}}:#[a-zA-Z]##:*})
[[ $#properties -gt 0 ]] && _store_cache "mvn/plugins/${plugin}/${goal}" properties
fi
[[ $#properties -gt 0 ]] && _describe -t "${plugin}-${goal}-property-names" "${plugin}:${goal} property name" properties -qS= && ret=0
return ret
}
(( $+functions[_mvn_property_values] )) ||
_mvn_property_values() {
local property="${(P)${#}}" ret=1
case $property in
file) _wanted file expl 'file' _files && ret=0;;
pomFile) _wanted pom-file expl 'POM file' _mvn_pom_files && ret=0;;
@ -373,43 +424,6 @@ _mvn_properties() {
user|username) _wanted user expl 'user' _users && ret=0;; # TODO Use _alternative and add repository usernames from settings + projects
*) _default && ret=0;;
esac
else
local alternatives; alternatives=(
'maven properties:maven property:_mvn_maven_properties'
)
for plugin_colon_goal in ${(M)words:#*:*}; do # FIXME pretty sure this matches more than just plugin:goals
alternatives+=("plugin properties:plugin property:_mvn_plugin_goal_properties '${plugin_colon_goal%:*}' '${plugin_colon_goal#*:}'")
done
_alternative "${alternatives[@]}" && ret=0
fi
return ret
}
(( $+functions[_mvn_maven_properties] )) ||
_mvn_maven_properties() {
# TODO Split in properties with values/properties without
local properties; properties=(
'skipTests:skip tests execution'
'maven.test.skip:skip tests compilation and execution'
'gpg.passphrase:gpg passphrase'
)
_describe -t 'maven-properties' "Maven property" properties -qS=
}
(( $+functions[_mvn_plugins_goals_properties] )) ||
_mvn_plugin_goal_properties() {
local plugin="${(P)$(($# -1))}" goal="${(P)${#}}" update_policy ret=1
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _mvn_plugin_goal_properties_caching_policy
unset properties
if ( [[ ${+properties} -eq 0 ]] || _cache_invalid "mvn/plugins/${plugin}/${goal}" ) && ! _retrieve_cache "mvn/plugins/${plugin}/${goal}"; then
properties=(${(M)${(ps:,,,:)${${${${(pj: :)${${${(f)${"$(_call_program goals $words[1] -N org.apache.maven.plugins:maven-help-plugin:2.1.1:describe -Dplugin=$plugin -Dgoal=$goal -Ddetail)"#*Available parameters:}%%\[INFO\]*}//# [a-z]*/,,,}##*Expression: \$\{}}//\}[[:space:]]##/:}//[[:space:]]##/ }//[[:space:]]#,,,[[:space:]]#/,,,}}:#[a-zA-Z]##:*})
[[ $#properties -gt 0 ]] && _store_cache "mvn/plugins/${plugin}/${goal}" properties
fi
[[ $#properties -gt 0 ]] && _describe -t "plugin-${plugin}-${goal}-properties" "${plugin}:${goal} property" properties -qS= && ret=0
return ret
}
@ -495,7 +509,7 @@ _mvn_plugin_goals_caching_policy() {
(( $#oldp ))
}
_mvn_plugin_goal_properties_caching_policy() {
_mvn_plugin_goal_property_names_caching_policy() {
_mvn_plugin_goals_caching_policy
}