ant: failed to create task or type if

ant: failed to create task or type if


 <target name="compile-cxcdata-dao">
    < if>
      <equals arg1="${dummyDAO}" arg2="true" />
      <then>
        <ant antfile="${data.dir}/data_build.xml" target="compile-data" />
        <mkdir dir="${apps.jar.dir}" />
        <jar jarfile="${apps.jar.dir}/data.jar">
          <fileset dir="${data.classes.dir}" includes="**/*" />
        </jar>
      </then>
      < else>
        <copy todir="${apps.jar.dir}" overwrite="true">
          <fileset dir="${data.dir}" includes="**/*.jar" />
        </copy>
      </ else>
    </ if>
  </target>

BUILD FAILED
D:\__workspace_svn\apps\build.xml:18: The following error occurred while executing this line:
D:\__workspace_svn\apps\apps_build.xml:145: The following error occurred while executing this line:
D:\__workspace_svn\apps\apps_build.xml:100: The following error occurred while executing this line:
D:\__workspace_svn\apps\apps_build.xml:71: Problem: failed to create task or type if
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.

Solution:
It is a compatibility issue.
1. 
Right click on build.xml.

2.
Go to "Run As" --> 2 Ant  Select Classpath tab check Ant Home version (Sometimes eclipse selects  default ant version).
If the version listed is different, then change Ant Home Classpath to C:\XXXX\ant\X.X.X.

3.
Finally click on the Classpath tab --> Add External JARS..--> add ant-contrib.x.x.jar from C:\XXXX\ant\X.X.X\ant-contrib\ directory.

你可能感兴趣的:(ant: failed to create task or type if)