<project name="My Project" default="all" basedir=".">
  <description>
    Buildfile for the My Project
  </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="extLib" location="extLib"/>
  <property name="antBuild" location="antBuild"/>
  <property name="classes" location="${antBuild}/classes"/>
  <property name="dist" location="${antBuild}/lib"/>
  <property name="javadocs" location="docs/javadocs"/>
  <property name="bin" location="bin"/>

  <!--Sets up the classpaths correctly, not meant to be called directly-->
  <target name="init">
    <echo>Constructing classpath</echo>

    <path id="classpath">
      <fileset dir="${extLib}" id="extLibs"> <!--//used for jarDepen-->
        <include name="*.jar"/>
      </fileset>
    </path>
    <property name="temp" refid="classpath"/>
    <echo>Using classpath: ${temp}</echo>
  </target>

  <target name="compile" depends="init" description="compile the source ">
    <mkdir dir="${classes}"/>

    <echo>Copying images</echo>
    <copy todir="${classes}/pathToIcons/icons">
      <fileset dir="${src}/pathToIcons/icons">
      </fileset>
    </copy>

    <!-- Compile the java code from ${src} into ${classes} -->
    <javac debug="true" srcdir="${src}" destdir="${classes}">
      <classpath refid="classpath"/>
    </javac>
  </target>

  <target name="jar" depends="init, compile" description="generate the jar file" >
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}"/>
    <!-- Put everything in ${build} into .jar file -->
    <jar jarfile="${dist}/output.jar" basedir="${classes}">
      <manifest>
        <attribute name="Main-Class" value="path.to.MainClass"/>
      </manifest>
    </jar>
  </target>

  <target name="jarDepen" depends="init, compile" description="generate the jar file plus the dependancies" >
    <!-- Put everything in ${build} into .jar file -->
    <mkdir dir="${dist}"/>
      <jar jarfile="${dist}/output_and_depend.jar" basedir="${classes}">
      <manifest>
        <attribute name="Main-Class" value="path.to.MainClass"/>
      </manifest>
      <zipgroupfileset refid="extLibs"/>
    </jar>
  </target>
  <target name="javadocs" depends="init, compile" description="Generate the javadocs">
    <mkdir dir="${javadocs}"/>
    <!--Create the javadocs-->
    <javadoc destdir="${javadocs}" windowtitle="My Project " Doctitle="My Project Classes">
      <package name="*"/>
      <classpath refid="classpath"/>
      <sourcepath location="${src}"/>
    </javadoc>
  </target>
  <target name="all" depends="init, clean, compile, jar, jarDepen, javadocs" description="cleans, compiles, jars, docs"/>

</project>