It’s really frustrating to me that doing something ever so slightly differently leads to such drastically different results when dealing with software. It’s true that software engineers (if you’re curious about the treatment of the word engineer, then just call me on TokBox me and I’ll explain) tend to be the harshest critics of software, and that it’s hard to impress someone who thinks that they know how to do it better. Every software engineer thinks that they know how to do it better.

With that disclaimer, I want to complain a bit about some behavior that I found in working with Ant.

I don’t know how to do Ant better than the creators of Ant have. It’s not my favorite tool, but if I had to use makefiles, then I would stop developing code. I don’t think whether I use hardtabs or softtabs should determine the validity of my code. That, however, is a different rant. However, I was very surprised to find that when using the <foreach> tag in an Ant script, that it doesn’t inherit the properties that have been set so far. Instead, you have to expressly define what properties to pass into the <foreach> tag. As an example:

target: buildinfo
<property name="tokbox.build.num" value="${current.time}"/>

target: getcssfiles
<foreach target="compile-css" param="the_file">
    <path>
        <fileset dir="${localedir}">
            <include name="*.css"/>
        </fileset>
    </path>
</foreach>

The <foreach> loop doesn’t know that the tokbox.build.num property exists. Every other target does, but the <foreach> doesn’t. However, if I were to add:

<param name="tokbox.build.num" value="${tokbox.build.num}" />

into my <foreach> loop, then it not only knows the build number, but everything builds! The final code ends up looking like this:


<foreach target="compile-css" param="the_file">
    <param name="tokbox.build.num" value="${tokbox.build.num}" />

    <path>
        <fileset dir="${localedir}">
            <include name="*.css"/>
        </fileset>
    </path>
</foreach>