我如何通过参数传递给一个Ant任务? [英] How do I pass an argument to an Ant task?

查看:178
本文介绍了我如何通过参数传递给一个Ant任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是很好的蚂蚁,但我们使用它作为构建工具。现在,我们可以运行蚂蚁测试,它会通过所有的单元测试运行。

I'm not very good with Ant, but we're using it as a build tool. Right now, we can run "ant test" and it'll run through all the unit tests.

不过,我很想能够做到像蚂蚁测试some_module ,并让它接受 some_module 作为一个参数,并且只测试

However, I'd love to be able to do something like ant test some_module and have it accept some_module as a parameter, and only test that.

我一直没能找到如何命令行参数传递到Ant - ?任何想法

I haven't been able to find how to pass command line args to Ant - any ideas?

推荐答案

一个解决方法可能如下。 (我有一个项目,做到这一点。)

One solution might be as follows. (I have a project that does this.)

有类似测试一个单独的目标一个文件集,限制测试只有一个类。然后通过使用这个类的名称 -D 在蚂蚁命令行:

Have a separate target similar to test with a fileset that restricts the test to one class only. Then pass the name of that class using -D at the ant command line:

ant -Dtest.module=MyClassUnderTest single_test

在build.xml文件(高度降低):

In the build.xml (highly reduced):

<target name="single_test" depends="compile" description="Run one unit test">
    <junit>
        <batchtest>
            <fileset dir="${test.dir}" includes="**/${test.module}.class" />
        </batchtest>
    </junit>
</target>

这篇关于我如何通过参数传递给一个Ant任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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