在任务名称中使用连字符运行 Ant 任务的命令行 [英] Command line to run the Ant task with hyphen in the task name
本文介绍了在任务名称中使用连字符运行 Ant 任务的命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任务名称以连字符-"开头.
The task name starts with a hyphen "-".
<?xml version="1.0" encoding="UTF-8"?>
<project name="proj">
<target name="-task1">
<echo>Done!</echo>
</target>
</project>
从命令行运行 ant 脚本时如何指定此任务?这行不通:
How can I specify this task when running ant script from command line? This would not work:
ant -task1 -f test.xml
推荐答案
用引号将任务名称括起来.
Enclose the task name in quotes.
ant "-task1" -f test.xml
更新:来自 Ant 文档
Targets beginning with a hyphen such as "-restart" are valid,
and can be used to name targets that should not be called directly
from the command line.
For Ants main class every option starting with hyphen is an option for Ant itself
and not a target. For that reason calling these target from command line is not
possible. On the other hand IDEs usually don't use Ants main class as entry
point and calling them from the IDE is usually possible.
这篇关于在任务名称中使用连字符运行 Ant 任务的命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文