【问题标题】:Error while running ant build.xml运行 ant build.xml 时出错
【发布时间】:2015-01-16 17:31:49
【问题描述】:

您好,下面是我从命令提示符运行代码时的代码,因为 ant run iam 得到错误为

ERROR:
F:\xxx\build.xml:29: Problem: failed to create task or type target
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.

这是我的代码:

    <target name="checkout" description="checkout the code from Perforce">
        <exec executable="cmd">
            <arg value="/c"/>
            <arg value="p4 -u -p sync"/>
            <arg value="-p"/>
        </exec>
    </target>
    <target name="getlatestcode" description="checkout and get latest code from perforce">
        <exec executable="cmd">
            <arg value="/c"/>
            <arg value="p4"/>
            <arg value="-p"/>
        </exec>
    </target>
    <target name="cordovabuild" description="Getting the code and build the project">
        <exec executable="cmd">
            <arg value="/c"/>
            <arg value="p4"/>
            <arg value="-p"/>
        </exec>
    </target>

    <target name="run">
            <target name="checkout"/>
            <target name="getlatestcode" depends="checkout"/>
            <target name="cordovabuild" depends="getlatestcode"/>
            <target name="run" depends="cordovabuild,getlatestcode,checkout"/>
    </target>

【问题讨论】:

    标签: xml ant build compiler-errors build.xml


    【解决方案1】:

    你在目标中有目标,这是 Ant 不喜欢的,如下所示。

    <target name="run">
        <target name="checkout"/>
        <target name="getlatestcode" depends="checkout"/>
        <target name="cordovabuild" depends="getlatestcode"/>
        <target name="run" depends="cordovabuild,getlatestcode,checkout"/>
    </target>
    

    您应该有一个独立的目标,并且您可以在依赖项中具有依赖项,就像上面的 run(一个在 run 中)一样。删除最外面的运行目标及其相应的结束标记,使其看起来像:

    <target name="checkout"/>
    <target name="getlatestcode" depends="checkout"/>
    <target name="cordovabuild" depends="getlatestcode"/>
    <target name="run" depends="cordovabuild,getlatestcode,checkout"/>
    

    要运行你的运行目标,你可以发出ant run(构建文件名是可选的,假设根据你的错误你在build.xml中有这些)

    【讨论】:

      猜你喜欢
      • 2015-02-01
      • 2015-06-24
      • 1970-01-01
      • 2016-01-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多