使用不同的参数多次调用ant目标 [英] Call ant target multiple times with different parameters
问题描述
在Ant中是否可以使用不同的参数多次调用同一目标?
Is it possible in Ant to call the same target multiple times with different parameters?
我的命令如下所示:
ant unittest -Dproject='proj1' unittest -Dproject='proj2'
问题在于,单元测试只能运行两次,但仅适用于proj2:
The problem is that unittest gets run twice, but only for proj2:
unittest:
[echo] Executing unit test for project proj2
unittest:
[echo] Executing unit test for project proj2
我知道我可以运行两个单独的ant命令,但这将导致单元测试报告文件出现其他问题.
I know that I can run two separate ant commands, but that is going to cause additional problems with the unit test report files.
推荐答案
您可以使用
输出: 或者,您可以将单元测试目标更改为 macrodef : Alternatively, you could change the unittest target to be a macrodef: 这篇关于使用不同的参数多次调用ant目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!test:
unittest:
[echo] project=proj1
unittest:
[echo] project=proj2
BUILD SUCCESSFUL
Total time: 0 seconds
<project name="test" default="test">
<target name="test">
<unittest project="proj1"/>
<unittest project="proj2"/>
</target>
<macrodef name="unittest">
<attribute name="project"/>
<sequential>
<echo message="project=@{project}"/>
</sequential>
</macrodef>
</project>