alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (depend.xml)

This example Ant source code file (depend.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

a, a, ant's, ant's, b, b, e, e

The depend.xml source code

<?xml version="1.0"?>

<project name="depend" basedir="." default="help">
  <property name="src1.dir" value="src1"/>
  <property name="src2.dir" value="src2"/>
  <property name="src3.dir" value="src3"/>
  <property name="src4.dir" value="src4"/>
  <property name="src5.dir" value="src5"/>

  <property name="tempsrc.dir" value="working"/>
  <property name="cache.dir" value="working"/>
  <property name="classes.dir" value="classes"/>
  <target name="help">
    <echo>This buildfile is used as part of Ant's test suite.
  </target>

  <target name="basesetup" depends="clean">
    <mkdir dir="${tempsrc.dir}"/>
  </target>

  <target name="src1setup" depends="basesetup">
    <copy todir="${tempsrc.dir}">
      <fileset dir="${src1.dir}"/>
    </copy>
  </target>

  <target name="src2setup" depends="basesetup">
    <copy todir="${tempsrc.dir}">
      <fileset dir="${src2.dir}"/>
    </copy>
  </target>

  <target name="src3setup" depends="basesetup">
    <copy todir="${tempsrc.dir}">
      <fileset dir="${src3.dir}"/>
    </copy>
  </target>

  <target name="src4setup" depends="basesetup">
    <copy todir="${tempsrc.dir}">
      <fileset dir="${src4.dir}"/>
    </copy>
  </target>

  <target name="src5setup" depends="basesetup">
    <copy todir="${tempsrc.dir}">
      <fileset dir="${src5.dir}"/>
    </copy>
  </target>

  <target name="compile">
    <mkdir dir="${classes.dir}"/>
    <javac srcdir="${tempsrc.dir}" destdir="${classes.dir}"/>
  </target>

  <target name="clean">
    <delete dir="${classes.dir}"/>
    <delete dir="${tempsrc.dir}"/>
  </target>

  <target name="testdirect" depends="src1setup, compile">
    <sleep seconds="3"/>
    <delete file="${tempsrc.dir}/C.java"/>
    <copy file="${src1.dir}/C.java" tofile="${tempsrc.dir}/C.java"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}"/>
    <fileset id="result" dir="${classes.dir}"/>
  </target>

  <target name="testclosure" depends="src1setup, compile">
    <sleep seconds="3"/>
    <delete file="${tempsrc.dir}/C.java"/>
    <copy file="${src1.dir}/C.java" tofile="${tempsrc.dir}/C.java"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
    <fileset id="result" dir="${classes.dir}"/>
  </target>

  <target name="testbasicset" depends="src1setup, compile">
    <classfileset id="result" dir="${classes.dir}" rootclass="A"/>
  </target>

  <target name="testsmallset" depends="src1setup, compile">
    <classfileset id="result" dir="${classes.dir}" rootclass="B"/>
  </target>

  <target name="testresourcecollection" depends="testsmallset">
    <fail>
      <condition>
        <not>
          <and>
            <resourcecount count="2" refid="result" />
            <resourcecount count="1">
              <intersect>
                <resources refid="result" />
                <file file="${classes.dir}/B.class" />
              </intersect>
            </resourcecount>
            <resourcecount count="1">
              <intersect>
                <resources refid="result" />
                <file file="${classes.dir}/C.class" />
              </intersect>
            </resourcecount>
          </and>
        </not>
      </condition>
    </fail>
  </target>

  <target name="testcomboset" depends="src1setup, compile">
    <classfileset id="result" dir="${classes.dir}" rootclass="B">
      <include name="**/C.class"/>
    </classfileset>
  </target>

  <target name="testbyreference" depends="src1setup, compile">
    <classfileset id="classSet" dir="${classes.dir}" rootclass="A">
      <include name="**/C.class"/>
    </classfileset>
    <jar destfile="${tempsrc.dir}/test.jar">
      <fileset refid="classSet"/>
    </jar>
  </target>

  <target name="testmethodparam" depends="src1setup, compile">
    <classfileset id="result" dir="${classes.dir}" rootclass="E"/>
  </target>

  <target name="testinner" depends="src2setup, compile">
    <sleep seconds="3"/>
    <delete file="${tempsrc.dir}/B.java"/>
    <copy file="${src2.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
    <fileset id="result" dir="${classes.dir}"/>
  </target>

  <target name="testinnerinner" depends="src3setup, compile">
    <sleep seconds="3"/>
    <delete file="${tempsrc.dir}/B.java"/>
    <copy file="${src3.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
    <fileset id="result" dir="${classes.dir}"/>
  </target>

  <target name="testmethodparaminner" depends="src4setup, compile">
    <classfileset id="result" dir="${classes.dir}" rootclass="test.MethodParam"/>
  </target>  

  <target name="testnosource" depends="src1setup, compile">
    <depend destdir="${classes.dir}" closure="yes"/>
  </target>

  <target name="testemptysource" depends="src1setup, compile">
    <depend srcdir="" destdir="${classes.dir}" closure="yes"/>
  </target>

  <target name="testinnerclosure" depends="src4setup">
    <mkdir dir="${classes.dir}"/>
    <path id="path.compile">
        <pathelement location="${classes.dir}"/>
    </path>

    <javac srcdir="${tempsrc.dir}" destdir="${classes.dir}"
           classpathref="path.compile"/>

    <sleep seconds="3"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" 
            closure="yes" dump="yes"
            classpathref="path.compile"/>

    <fileset id="result" dir="${classes.dir}"/>
  </target>

  <target name="testcache" depends="src1setup, compile">
    <depend cache="${cache.dir}" srcdir="${tempsrc.dir}" 
            destdir="${classes.dir}" closure="yes"/>
    <depend cache="${cache.dir}" srcdir="${tempsrc.dir}" 
            destdir="${classes.dir}" closure="yes"/>
  </target>

  <target name="testnonpublic" depends="src5setup, compile">
    <sleep seconds="3"/>
    <delete file="${tempsrc.dir}/B.java"/>
    <copy file="${src2.dir}/B.java" tofile="${tempsrc.dir}/B.java"/>
    <depend srcdir="${tempsrc.dir}" destdir="${classes.dir}" closure="yes"/>
    <fileset id="result" dir="${classes.dir}"/>
  </target>
</project>

Other Ant examples (source code examples)

Here is a short list of links related to this Ant depend.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.