Ant: Available task for multiple files

Today I wanted to find out, using Ant, if any of a set of files existed. Based on that information, I would conditionally execute a target. Well, really I needed to solve a problem in Maven, but an Ant solution would plug in just fine. Here’s what I came up with:

<project name="test" default="test" basedir=".">
    <target name="test">
        <delete file="target\dir\status.file"/>
        <copy todir="target\dir">
            <fileset dir="target\dir" includes="*.xml"/>
            <mapper type="merge" to="status.file"/>
        </copy>
        <available property="test.any" value="true" file="target\dir\status.file"/>
        <property name="test.any" value="false"/>
        <echo>any.xml: ${test.any}</echo>
    </target>
</project>

That seems to work. The side effect is that one file is duplicated exactly, but only one.

Pebble 1.5

I’ve just tried to checkout Pebble’s source, and build the evolving version of 1.5. I couldn’t do it. There weren’t any instructions on building that I saw, so I tried a few things.

  • Run the setenv.bat file. This seemed to mess up my ANT_HOME.
  • Run ant -projecthelp. This gave me a NullPointerException.
  • Run ant. This gives me TagUnitTask cannot be found.

I don’t have the time or energy to dig in and figure out how the build system works, so for now I’ll wait. It’s hard to have all of the Prime Directives right all of the time.