In my previous post I blogged about my attempts to replace XML-based syntax for invoking Ant tasks using Jython scripts. But I wasn't fully satisfied with the result - I did not like that fact that I had to pass a task name as a parameter to PAnt.execTask, e.g.
pant.execTask("mkdir", dir=buildDir). It just was not intuitive enough. In Ant a task is equivalent to a subroutine, so I really wanted to use the task name as a function name. So I played a bit with dynamic dispatching in Jython and after a simple override of
__getattr__ I was able to invoke Ant tasks using this syntax:
PAnt (my Ant wrapper) treats any method call as a request to execute an Ant task (except for explicit calls to "execTask" method). This allows for an elegant (in my mind) and concise syntax. The updated PAnt script can be downloaded from here.
Meanwhile, I've started using this wrapper in earnest in a large-scale enterprise build system that I'm working on. So far, I've been absolutely thrilled with the results. This makes writing any non-trivial Ant target so much easier. I'm really hoping that this could make build script development less dull and daunting.
Please refer to our official PAnt project page for more information and to download PAnt
Do you have any example Jython scripts you can post that implements your PAnt lib?
Yes, see here: http://myarch.com/jython-ant-wrapper-examples. More to come.