Search code examples
antbuildbuild-process

Target Clean does not exist in the project dir


I have installed Ant in my centos 6.3 , installed location are /opt/ant and also ANT_HOME env are same

I have created build.xml to test by deleting testdir. This directory exist in the /opt/ant/testdir like this.

build.xml

<?xml version="1.0"?>
<project name="testdir" default="all" basedir=".">
  <property name="src"   value="src"/>
    <property name="build" value="build"/>
      <property name="lib"   value="lib"/>

    <target name="all" depends="clean, compile" description="Builds the whole project">
        <echo>Doing all</echo>
    </target>

    <target name="clean">
        <echo message="Deleting bin/java ..." />
        <delete dir="testdir/test" />
    </target>
</project>

Using Command :-

    ant -buildfile build.xml Clean

getting error:-

    BUILD FAILED
    Target "Clean" does not exist in the project "testdir".

Any suggestion to make it work?


Solution

  • I have found solution. I missed target="compile" block in build.xml.

    <target name="compile">
        <echo message="Compiling source code"/>
    </target>
    

    Run command :-

    ant clean