prezto_config/plugins/ant/init.zsh

28 lines
577 B
Bash
Raw Normal View History

2011-08-31 05:16:15 +02:00
if stat -f%m . &> /dev/null; then
stat_cmd=(stat -f%m)
else
2011-08-31 05:16:15 +02:00
stat_cmd=(stat -L --format=%Y)
fi
2011-08-31 05:16:15 +02:00
function _ant_does_target_list_need_generating() {
if [[ ! -f .ant_targets ]]; then
return 0
2010-11-25 21:48:07 +01:00
else
accurate=$($stat_cmd .ant_targets)
changed=$($stat_cmd build.xml)
2010-11-25 21:48:07 +01:00
return $(expr $accurate '>=' $changed)
fi
}
2011-08-31 05:16:15 +02:00
function _ant() {
if [[ -f build.xml ]]; then
2010-11-25 21:48:07 +01:00
if _ant_does_target_list_need_generating; then
2011-08-31 05:16:15 +02:00
sed -n '/<target/s/<target.*name="\([^"]*\).*$/\1/p' build.xml > .ant_targets
2010-11-25 21:48:07 +01:00
fi
compadd `cat .ant_targets`
fi
}
compdef _ant ant
2011-08-31 05:16:15 +02:00