运行ant build.xml时出错

时间:2014-11-19 09:07:16

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

下面是我的代码当iam从命令提示符运行代码时作为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>

1 个答案:

答案 0 :(得分:0)

你的目标是目标,这是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>

你应该拥有一个独立的目标,并且你可以拥有依赖,就像你在上面运行(运行中的一个)一样。删除outper大多数运行目标及其相应的结束标记,使其看起来像:

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

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