通过命令行参数蚂蚁 [英] passing command line arguments to ant
问题描述
我在蚂蚁比较新的,在学校里我有一个任务做一个build文件。我的一个问题是复制到/ foldercopy的名字(或路径)作为论据蚂蚁的文件。我需要做的是这样的:
I am relatively new in ant, at school I have an assignment to do a build file. One of my questions is to copy to "/foldercopy" the file whose name(or path) is taken as argument for ant. I need to do something like:
蚂蚁cpfile file.txt的
ant cpfile file.txt
所以,蚂蚁将复制到file.txt文件/ foldercopy。我搜索了很多关于谷歌,但我能找到的东西是用-Darg,但我的老师说,这是不正确的。有没有办法做到这一点?
So ant will copy the file.txt to /foldercopy. I searched a lot on google but all I could find was something with "-Darg", but my teacher said that it's not correct. Is there any way to do it?
推荐答案
普通的命令行参数蚂蚁
被认为是目标名称,所以如果你想传递参数你的目标,你需要使用属性,通过 -D
:
Plain command line arguments to ant
are considered to be target names, so if you want to pass arguments to your target you need to use properties, via -D
:
ant -Dfile=file.txt cpfile
和访问值 $ {文件}
里面的build.xml
and access the value as ${file}
inside build.xml
这篇关于通过命令行参数蚂蚁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!