Enhanced handling for ant autocomplete.
Instead of assuming a build.xml, now -f <antfile.xml> can provide an alternative ant .xml file.
This commit is contained in:
parent
d2725d44fc
commit
80182975a4
@ -1,16 +1,33 @@
|
|||||||
_ant_does_target_list_need_generating () {
|
_ant_does_target_list_need_generating () {
|
||||||
[ ! -f .ant_targets ] && return 0;
|
local build_file=$1
|
||||||
[ build.xml -nt .ant_targets ] && return 0;
|
[ ! -f .ant_targets ] && return 0;
|
||||||
return 1;
|
[ $build_file -nt .ant_targets ] && return 0;
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ant () {
|
_ant () {
|
||||||
if [ -f build.xml ]; then
|
_arguments ':target:->target' '-f[build-file]:filename:->files'
|
||||||
if _ant_does_target_list_need_generating; then
|
|
||||||
ant -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
|
case "$state" in
|
||||||
fi
|
files)
|
||||||
compadd -- `cat .ant_targets`
|
compadd -- $(grep -l --color=never "<target" *.xml)
|
||||||
fi
|
;;
|
||||||
|
target)
|
||||||
|
build_file="build.xml"
|
||||||
|
if [[ "$words[2]" == "-f" ]]; then
|
||||||
|
build_file="$words[3]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#local build_file=$(ls (ant*.xml|build.xml))
|
||||||
|
if [ $? -eq 0 -a -f $build_file ]; then
|
||||||
|
if _ant_does_target_list_need_generating $build_file; then
|
||||||
|
ant -f $build_file -p | awk -F " " 'NR > 5 { print lastTarget }{lastTarget = $1}' > .ant_targets
|
||||||
|
fi
|
||||||
|
compadd -- $(cat .ant_targets)
|
||||||
|
fi
|
||||||
|
#_values 'target' a b c d e
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
compdef _ant ant
|
compdef _ant ant
|
||||||
|
Loading…
Reference in New Issue
Block a user