2
votes

i have an xml script for building a project out of this structure.

  • src
    • src files and package subdirs
  • rsrc
    • build.xml

After building out of the src folder there is a build and lib folder created in rsrc

  • src
    • src files and package subdirs
  • rsrc
    • build
      • package subdirs
    • lib
    • build.xml

After everything worked, the build folder is filled with the .class files, in their package subdirs. In the lib folder the distribution .jar has it's place. Now to my problem i wrote this target named= "clean":

  <target name="clean"
        description="clean up" >
        <!-- Delete the ${build} directory tree -->
        <delete dir="${build}"/>
  </target>

Which should delete the build folder, its subfolders and contents. The $ Build is defined as:

  <property name="build" location="build"/>

and the base directory as basedir="."

But nothing gets deleted, what am I doing wrong.

Best regards Stefan (If you need additional information just ask please)

EDIT: If i call it with "ant -v clean" the build file is deleted .. if i call with "ant" or "ant -verbose" its not.

5
Try running with ant -v clean. That will show you exactly what Ant is trying to delete. (And ignore the answers which recommend using ${basedir}/build—they apparently aren't aware that relative paths in Ant are already treated as relative to the basedir.)VGR
if you post this as answer you are my top voted :) thank you so muchStefan Sprenger

5 Answers

2
votes

Try running with ant -v clean. That will show you exactly what Ant is trying to delete. (And ignore the answers which recommend using ${basedir}/build—they apparently aren't aware that relative paths in Ant are already relative to the basedir.)

1
votes

Use property as below.

<property name="build" value="${basedir}/build"/>
1
votes

Try using ${basedir} instead. That will point to the parent directory of the buildfile. Also a common way to organize folders is to have your build.xml in the build folder and your output from building in build/output.

1
votes

Maybe you forgot to call the target "clean"?

Try executing your ant with -v flag so we can see the output ant generates in order to see if the target is executed.

To see if the directory is correct, you can add <echo message="${build}"/> (http://ant.apache.org/manual/Tasks/echo.html) in the target to verify the absolute path of the directory.

Hope it helps!

0
votes

make <target name="clean"> depend on init

<target name="init" depends="clean">
        code
    </target>