Error while running ant build.xml

620 views Asked by At

hi the below is my code when iam running the code from command prompt as ant run iam getting the error as

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.

This is my code:

    <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

There are 1 answers

0
SMA On

You have target within target which is what is not liked by Ant like below.

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

You should have one independent target and you could have dependencies in depends like you do for run (one within run) in above. Remove the outper most run target and its corresponding ending tag so it should look like:

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

And to run your run target, you could just issue ant run (build file name as optional, assuming as per your error you have these within build.xml)