ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ed Taekema <>
Subject RE: Article: Use Jython to Write Ant Tasks
Date Mon, 26 Apr 2004 03:47:09 GMT
Thanks for your feedback on my article.  Perhaps what I should have made a little clearer
was where my perspective on Ant builds was coming from.  My experience has been
almost completely large enterprise build system with 100s of developers and a great mix of

development tools Before ant, I would have relied entirely on Make/IMake just to show 
my age I suppose.

Please note that I didn't intend the article to be a slight against Ant, especially 
since recent releases have made bottom up builds much easier through <import> support
and <macrodef> lets you assemble things in creative ways.  (Ant is learning from
Make here or at least learning the same lessons).  The intent with the article was to lay
"How To" ground work for further explorations of using a scripting tool in a more integrated
Ant fashion. 

My own reasons for attempting this approach is that I need to quickly connect 
already written tools into a large ant build (deployment tools, synchronization tools, etc).
I could do it in a script, but it becames cumbersome to deploy and that is where a task
written in a high level language with all its libraries, tools etc comes in handy ...
especially if I can cross compile it into Java, jar it and deploy it anywhere where Java 
can run.

I'll post further examples and hopefully the reason why someone might want to try this will

Thanks again for your feedback.


Ed Taekema
Toronto, Canada

-----Original Message-----
From: Bill Rich <>
Sent: Apr 24, 2004 10:55 AM
To: Ant Users List <>, Ed Taekema <>
Subject: RE: Article:  Use Jython to Write Ant Tasks

I just read your article and applaud your approach to simplifying the writing of Ant tasks
although I don't understand why writing the code in jython is easier than writing the code
in Java.  But if that suits you so be it.

I also take some exception with a couple of your statements.

One statement is "Eventually, builds need to do either a lot of odd conditional logic in
the xml file and ends up burying the logic in scripts, or in a large number of custom
tasks written in java."

I am using Ant for process control rather than for just building executables.  My current
job is in localization (l10n) where I must make sure that the translatable strings in a
product are translated into whatever target language is needed.  We have designed a
process to extract the strings, prepare a Translation Request Package (TRP), send the TRP
out for translation, resurrect the appropriate files with the translated strings, and
build a localized product for testing.  In the process we use many tools written in-house
and purchased.  We use Ant to control when to run any of the tools that have a command
line interface (unfortunately some of the tools we use do not have a command line
interface so we are forced to deal with them separately).  We deal with many different
types of files such as Java LRB and PRB, MC, RC, HTML, JSP, and XML.  The process is
driven from a list of files maintained in an XML file.  Each file is described by its
type, source file name, and a target file name pattern.  I have been working with Ant for
about 6 weeks now and have the process control working pretty well.  I have written many
Ant targets, 5 macrodefs, and separated the pieces in 4 XML files that are imported as
needed.  I wrote 2 Ant tasks and abandoned them in favor of using pure Ant.  I also use
ant-contrib to help with logic control.  I have tried to keep the Ant code down to as
simple as possible but I have not succeeded in many cases because of my lack of
understanding of all the elements of Ant.  I am still learning and adjusting as I go.  The
process requires the repeated application of tools over the list of files and the
gathering and merging of some of the output files into a more manageable list of files.  I
use <if> and <for> a lot to control logic and I use the <macrodef> to make
sure the tasks
are consistent where needed.  I think we will try to integrate the product build into the
process soon but this is more complex since each product has its own build environment and
Ant files.  I seriously doubt that we will need any Ant tasks to complete the process
control work we are doing.

Another statement is "One of the strengths that Make always had was the ability to easily
call scripts and command utilities. This is something that is definitely possible with Ant
script/exec tasks, but it feels very un-java. What we need is an elegant way to add adhoc
behaviour to Ant builds ... in a java-ish way."

In my opinion it is not a good thing to try to make Ant like anything else.  Ant is what
Ant is and Ant feels like Ant.  Ant is not Java and should not be forced to look or feel
like Java.  To use Ant effectively you need to step into the Ant zone and think in Ant.
If something like the use of script/exec feels un-java so what, Ant is not Java.  The
important thing is does it feel un-Ant?  My answer is no it feels like it belongs in Ant
because it was designed to be there so use it.  Also in my opinion, there is no place for
"adhoc behaviour" in Ant or any other programming language.  All behavior should be
planned and carefully integrated into the system.  From Java up to the theory of Object
Oriented programming there is no place for adhoc behavior.  All objects have well defined
behavior and they stay within the confines of their spec.  If a new behavior is needed
then the spec is changed first or a new object is defined.  So if you need a new behavior
in a build, understand what it is you need then see if Ant or an already available
extension to Ant can provide it.  Then if no task is available you can decide to make the
Ant task to extend Ant.

Now a few random thoughts of my own on Ant.  I am very pleased with Ant and how easy it
has been for me to get into the Ant zone and begin understanding how to use Ant.  The
documentation is good, although there could be some better examples in a few places.  Eric
Hatcher's book is also very good but it is out of date now.  It helps to give the basic
understanding of the philosophy of Ant and how to think in Ant.  I have found that Ant is
easy to write and I found a documentation tool that worked pretty well once I tailored it
a little to get more information out of it.  To help myself in writing Ant code I created
a small clip file for use in TextPad so I can click on the construct name I want and a
model of the code is inserted in the file.  For the documentation I got a copy of ant2html
but found it did not list the macrodefs and left out all comments in the code.  I added
this to ant2html and it now produces more of what I want for documentation.  I think there
is more that can be done to add links and other documentation information to Ant but it
can come later.  The xsl file was fairly easy to modify and I may try some more
modifications later when I have more time.

Thanks.  Bill

Bill Rich
Wilandra Consulting LLC
1325 Addiewell Place
San Jose, CA  95120-3905
phone:      +1 408 268-2452
mobile:     +1 408 410-9713
Santa Cruz: +1 831 464-9007
fax:        +1 413 669-9716 or

-----Original Message-----
From: Ed Taekema []
Sent: Friday, April 23, 2004 8:27 PM
Subject: Article: Use Jython to Write Ant Tasks

I've written a guide to writing Ant tasks using Jython:  how to add scripted behaviour
to ant builds. It details the steps to write a custom Ant task in jython, compile
it and install it into ant so it can be used as any other task in an ant build.
The article also takes a quick look at an alternate implementation using Groovy.

And ... here is the url: .


Ed Taekema
Toronto, Canada

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message