Ant Scripting

I wrote a little while ago about Ant as a scripting language. The question, or a variation, has come up again with Jonathan Simon’s recent article (scroll down a bit for the stuff on Ant) and Duncan’s followup. Even my local JUG’s mailing list has gotten into this.

I found the comments on the two articles interesting. There are those looking for more scripting in Ant or a separate scripting language-based build system. There is also quite a few that oppose having more scripting in Ant. Ironically for both points of view, Ant has long supported the <script> task which would allow pretty much arbitrary scripting anyway. Yet it seems to me that users are not using <script>. They seem to prefer the XML based constructs. I think that it would be interesting to understand why that is. Is it the problems of changing models/modes-of-thought between tasks and scripts? Is it the complexity of the Ant object model once you get into the script?

My own contribution to the issue is the <scriptdef> task, which lets you create tasks in your build file using any BSF-supported scripting language. I thought it gave the benefit of scripting while exposing it to the rest of the build in an Ant-centric way. I think that combining this with Ant 1.6’s <import> task will be interesting. I did wonder, however, when I committed it, whether it should be part of Ant proper or hosted somewhere else, such as ant-contrib.

I also found this interesting wiki page, AntPractices, (via Andrew Newman). It contains a bit of a rant about the Ant Way, whatever that is. All I can say is that, IMHO, the Ant dev team is supportive of ant-contrib. After all Stefan is a member of that project and it relies on features such as TaskContainer and Sequential in the Core Ant that were put in precisely to facilitate such tasks for those who wanted to go that way.

I think most of the Ant developers struggle with the balance between supporting the needs of users, many of whom clearly want logic in their build processes and the desire not to turn Ant into a programming language. The current balance is to provide the underlying enablers for tasks such as ant-contrib’s logic tasks without making these part of the core Ant distribution. It certainly doesn’t come from any sort of dogma.