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

Ant example source code file (test.xml)

This example Ant source code file (test.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

at, at

The test.xml source code

<?xml version="1.0"?>

<project name="dependset-test" xmlns:au="antlib:org.apache.ant.antunit">

  <target name="test1">
    <au:expectfailure expectedMessage="At least one set of source resources must be specified">
      <dependset />
    </au:expectfailure>
  </target>

  <target name="test2">
    <au:expectfailure expectedMessage="At least one set of target files must be specified">
      <dependset>
        <srcfilelist dir="." files="test2.tmp" />
      </dependset>
    </au:expectfailure>
  </target>

  <target name="test3">
    <au:expectfailure expectedMessage="At least one set of source resources must be specified">
      <dependset>
        <targetfileset dir="." includes="test3.tmp" />
      </dependset>
    </au:expectfailure>
  </target>

  <target name="test4">
    <touch file="test4.tmp" />
    <dependset>
      <srcfilelist dir="." files="test4.tmp" />
      <targetfileset id="targetfs" dir="." includes="i-do-not-exist" />
    </dependset>
  </target>

  <target name="test5">
    <touch file="older.tmp" />
    <sleep seconds="3" />
    <touch file="newer.tmp" />
    <dependset>
      <srcfilelist dir="." files="newer.tmp" />
      <targetfilelist dir="." files="older.tmp" />
    </dependset>
    <au:assertFalse>
      <available file="older.tmp" />
    </au:assertFalse>
  </target>

  <target name="test6">
    <touch file="older.tmp" />
    <sleep seconds="3" />
    <touch file="newer.tmp" />
    <dependset>
      <sources>
        <file file="newer.tmp" />
      </sources>
      <targets>
        <filelist dir="." files="older.tmp" />
      </targets>
    </dependset>
    <au:assertFalse>
      <available file="older.tmp" />
    </au:assertFalse>
  </target>

  <target name="test7">
    <touch file="older.tmp" />
    <dependset>
      <sources>
        <propertyresource name="thereisnosuchproperty" />
      </sources>
      <targets>
        <filelist dir="." files="older.tmp" />
      </targets>
    </dependset>
    <au:assertFalse>
      <available file="older.tmp" />
    </au:assertFalse>
  </target>

  <target name="test8">
    <touch file="older.tmp" />
    <property name="foo" value="bar" />
    <dependset>
      <sources>
        <propertyresource name="foo" />
      </sources>
      <targets>
        <filelist dir="." files="older.tmp" />
      </targets>
    </dependset>
    <au:assertTrue>
      <available file="older.tmp" />
    </au:assertTrue>
  </target>

  <target name="test9">
    <au:assertFalse>
      <available file="test9dir" type="dir" />
    </au:assertFalse>
    <touch file="test9.tmp" />
    <dependset>
      <srcfileset dir="." includes="test9.tmp" />
      <targetfileset dir="test9dir" />
    </dependset>
  </target>

  <target name="tearDown"> 
    <delete file="test4.tmp" />
    <delete file="test9.tmp" />
    <delete file="older.tmp" />
    <delete file="newer.tmp" />
  </target>
</project>

Other Ant examples (source code examples)

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

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.