我如何通过参数传递给一个Ant任务? [英] How do I pass an argument to an Ant task?
问题描述
我不是很好的蚂蚁,但我们使用它作为构建工具。现在,我们可以运行蚂蚁测试,它会通过所有的单元测试运行。
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屋!