2012-11-19 60 views
1

我创建了一个内部有一些目标的蚂蚁项目。一个目标叫做info,它显示所有可用的目标。这个目标被设置为默认:蚂蚁手柄目标未找到

<project name="XXX" basedir="." default="info"> 

现在我想这个目标到目标的情况下,被称为未发现:

Target "infp" does not exist in the project "XXX" 

我需要这情况下,用户调用没有按”目标不存在。然后我想要显示信息,以便他看到所有可用的选项。

感谢

回答

2

ANT不支持此功能。如果在命令行中未指定目标,则会调用“默认”目标。

相反,我会建议让你的构建自我描述和教你的用户关于ANT 的-p选项。

下面的生成文件:

<project name="demo" default="welcome"> 

    <description> 
    The purpose of this build file is to explain how one 
    can make an ANT file self describing 
    </description> 

    <target name="welcome" description="Print a hello world message"> 
     <echo message="hello world"/> 
    </target> 

    <target name="do-somthing" description="Print a dummy message"> 
     <echo message="hello world"/> 
    </target> 

    <target name="do-somthing-silent"> 
     <echo message="hello world"/> 
    </target> 

</project> 

能描述自己如下:

$ ant -p 
Buildfile: /home/mark/build.xml 

    The purpose of this build file is to explain how one 
    can make an ANT file self describing 

Main targets: 

do-somthing Print a dummy message 
welcome  Print a hello world message 
Default target: welcome 
+0

感谢。我会接受这一点。 – bioShark