ant.plugin.zsh 567 B

1234567891011121314151617181920212223242526
  1. stat -f%m . > /dev/null 2>&1
  2. if [ "$?" = 0 ]; then
  3. stat_cmd=(stat -f%m)
  4. else
  5. stat_cmd=(stat -L --format=%Y)
  6. fi
  7. _ant_does_target_list_need_generating () {
  8. if [ ! -f .ant_targets ]; then return 0;
  9. else
  10. accurate=$($stat_cmd .ant_targets)
  11. changed=$($stat_cmd build.xml)
  12. return $(expr $accurate '>=' $changed)
  13. fi
  14. }
  15. _ant () {
  16. if [ -f build.xml ]; then
  17. if _ant_does_target_list_need_generating; then
  18. sed -n '/<target/s/<target.*name="\([^"]*\).*$/\1/p' build.xml > .ant_targets
  19. fi
  20. compadd `cat .ant_targets`
  21. fi
  22. }
  23. compdef _ant ant