Sample Ant clean, prepare, and compile tasks

Summary: An Ant clean, prepare, and compile example.

I'm not going to discuss the following Ant build script code too much, but I thought I would share it here. In short, it shows how I declare several Ant tasks, including my typical clean, prepare, and compile tasks.

<target name="clean">
  <echo>=== CLEAN ===</echo>
  <delete failonerror="false">
    <fileset dir="${dest.dir}" includes="**/*"/>
  <delete dir="${temp.dir}" />

<target name="prepare" depends="clean">
  <echo>=== PREPARE ===</echo>
  <mkdir dir="${dest.dir}" />
  <mkdir dir="${temp.dir}" />
  <mkdir dir="${temp.dir.lib}" />
  <mkdir dir="${temp.dir.meta-inf}" />
  <mkdir dir="${temp.dir.web-inf}" />
  <mkdir dir="${temp.dir.classes}" />

<target name="compile" depends="prepare">
  <echo>=== COMPILE ===</echo>
  <echo>Compiling ${src.dir} files ...</echo>
  <javac debug="on" srcdir="${src.dir}" destdir="${temp.dir.classes}" includes="**/*">
    <classpath refid="build.class.path" />

  <!-- compile files on the src-tests path -->
  <echo>Compiling ${src.tests.dir} files ...</echo>
  <javac debug="on" srcdir="${src.tests.dir}" destdir="${temp.dir.classes}" includes="com/**">
    <classpath refid="build.class.path" />

That may not make sense if you're not already somewhat comfortable with Ant tasks and variables, but I thought I'd share it in case you just need a little Ant build task reference/template to copy from.