命令行与任务的名字连字符运行Ant任务 [英] Command line to run the ANT task with hyphen in the task name

查看:126
本文介绍了命令行与任务的名字连字符运行Ant任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任务名称以连字符开始 - 。

 <?XML版本=1.0编码=UTF-8&GT?;
<项目名称=凸出>
    <目标名称= - 独立写作>
        <回声>完成<!/回声>
    < /目标与GT;
< /项目>

如何可以从命令行运行Ant脚本时,我指定这个任务?这是行不通的:

 蚂蚁-task1 -f的test.xml


解决方案

在引号将任务名称。

 蚁族-task1-f的test.xml

更新:
蚂蚁文档

 以连字符开头的目标,比如-restart是有效的,
和可用于不应该直接调用名的目标
在命令行。
蚂蚁主类开始连字符每一个选项是蚂蚁本身的选项
而不是一个目标。出于这个原因调用这些目标的命令行不
可能。在另一方面的IDE通常不使用蚂蚁主类作为进入
指向和从IDE调用它们通常是可能的。

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>

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

Update: From Ant docs

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

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