使用不同的参数多次调用ant目标 [英] Call ant target multiple times with different parameters

查看:126
本文介绍了使用不同的参数多次调用ant目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在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.

推荐答案

您可以使用

输出:

test:

unittest:
     [echo] project=proj1

unittest:
     [echo] project=proj2

BUILD SUCCESSFUL
Total time: 0 seconds

或者,您可以将单元测试目标更改为 macrodef :

Alternatively, you could change the unittest target to be a macrodef:

<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>

这篇关于使用不同的参数多次调用ant目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆