Listing B
<project name="myapp" default="jar">
 
 
  <!-- where the project source code is found -->
  <property name="sources" value="src"/>
 
 
  <!-- where compiled class files should be left -->
  <property name="classes" value="classes"/>
 
 
  <target name="jar" depends="pre-jar,classes"
      description="build release jar">
    <jar destfile="jar/${ant.project.name}.jar">
      <fileset dir="classes">
        <include name="**/*.class"/>
      </fileset>
    </jar>
  </target>
 
 
  <target name="pre-jar" depends="ensure-release">
    <property name="srcdir" value="jar/src"/>
    <mkdir dir="${srcdir}"/>
    <copy todir="${srcdir}">
      <fileset dir="${sources}">
        <include name="**/*.java"/>
      </fileset>
      <filterset>
        <filter token="RELEASE" value="${release}"/>
      </filterset>
    </copy>
  </target>
 
 
  <target name="ensure-release" unless="release">
    <fail message="You must define -Drelease=&lt;name&gt;"/>
  </target>
 
 
  <target name="classes" description="compile classes">
    <property name="srcdir" value="${sources}"/>
    <mkdir dir="${classes}"/>
    <echo message="srcdir=${srcdir}"/>
    <javacdestdir="${classes}" srcdir="${srcdir}">
    </javac>
  </target>
 
 
  <target name="clean" depends="tidy" description="delete all generated files">
    <delete dir="jar" quiet="true"/>
  </target>
 
 
  <target name="tidy" description="delete all intermediary files">
    <delete dir="jar/src" quiet="true"/>
    <delete dir="classes" quiet="true"/>
  </target>
 
 
</project>