Ant构建目标以列出自己的构建目标

Mat*_*son 2 ant

我是Ant的新手.我想要以下内容:

<target name="targets" description "Lists Targets">
  [some Ant code/tasks]
</target
Run Code Online (Sandbox Code Playgroud)

当我打电话时,ant targets我希望Ant搜索Ant正在为其所有目标运行的当前文件

<target name="all" depends="doc,sca,compile,test" description="Complete build">
</target>
Run Code Online (Sandbox Code Playgroud)

并输出

[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
Run Code Online (Sandbox Code Playgroud)

BashMake我只是做一个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
Run Code Online (Sandbox Code Playgroud)

输出:

[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
Run Code Online (Sandbox Code Playgroud)

在我的Ant构建脚本中有一些simliar会很高兴!如果Ant可以进行良好的对齐,pr甚至可以为输出着色,那将会特别好!Ant可以跨平台终端颜色变化吗?

JB *_*zet 6

您可以使用ant -p(或ant -p -v获取更多信息).这不会列出目标依赖项,但我不认为它是一个问题:依赖项对最终用户来说并不重要(它们只是告诉目标是如何工作的).最重要的是什么样的目标呢,这是应该在其描述的内容.