【发布时间】:2011-09-28 16:23:39
【问题描述】:
我是 Ant 的新手。我想要以下内容:
<target name="targets" description "Lists Targets">
[some Ant code/tasks]
</target
当我调用 ant targets 时,我希望 Ant 搜索 Ant 正在运行的当前文件中的所有目标
<target name="all" depends="doc,sca,compile,test" description="Complete build">
</target>
然后输出
[echo] all - Complete Build - Depends on: doc, sca, compile, test
[echo] doc - Builds documentation
[echo] compile - Compiles files
[echo] sca - Performs static code analysis
[echo] test - Runs unit tests - Depends on: compile
[echo] clean - Cleans a build
[echo] install - Performs an installation
[echo] targets - Lists Targets
在Bash 或Make 中,我只需要一个grep 正则表达式。以下Make 中列出了 make 目标:
noop: ;
targets:
@$(MAKE) --print-data-base --question noop | \
grep -v "[A-Z]:/" | \
awk '/^[Mm]akefile:/ { next } \
/^targets:/ { next } \
/^noop:/ { next } \
/^[^.%!][-A-Za-z0-9_]*:/ { print substr($$1, 1, length($$1)-1) }' | \
sort | \
pr --omit-pagination --width=80 --columns=4
输出:
[matt@office burning-boots-website]$ make -C ~/workspace/packages/ targets
all diagnose install vca_core
clean doc platforms vca_counting_line
compile help utils vca_rules
如果在我的 Ant 构建脚本中有类似的东西会很好!如果 Ant 能够像 pr 那样进行良好的对齐,甚至为输出着色,那就太好了! Ant可以跨平台终端换色吗?
【问题讨论】:
-
ant -p 不够用,这个命令行选项会列出所有目标吗? ant.apache.org/manual/running.html
标签: ant