AINASL: Ant Is Not a Scripting Language

After looking at the example project and buildfile, you may begin to look at Ant as a sort of scripting language for builds. With this bit of insight, you may charge forward writing buildfiles with this concept in mind...until the wheels fall off and you’re stuck wondering why Ant can’t do something you’d expect of any scripting language. Here’s why they fell off: XML does not make for a good scripting language.

In a way, you’re excused for seeing Ant as a sort of XML scripting language and accompanying parser. The difference is that, viewed as a scripting language, Ant is not very good. In fact, it’s horrible. This little oddity of perception can cause a lot of confusion and frustration. Viewing the build as a design and not as a series of steps helps alleviate this confusion. We champion this authoring technique. So where does Ant’s XML syntax fail as a scripting language?

Look Ma, No Data Structures!

A more concrete example of an oddity in Ant’s syntax is its management of data. Here, the closest analogy to a language variable is the <property> tag. This, of course, completely ignores the rich data capabilities of XML, and Ant’s developers know this. In addition to the property, there is the concept of an Ant data element — for example, the path DataType. The limitation is you cannot create DataTypes “in-language,” as you can with a scripting language. Instead, you must write a class (or a set of classes) to represent a new data type in ...

Get Ant: The Definitive Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.