ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bill Rich" <billr...@attglobal.net>
Subject RE: Article: Use Jython to Write Ant Tasks
Date Sat, 24 Apr 2004 16:55:16 GMT
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
billrich@wilandra.com or billrich@attglobal.net
http://www.wilandra.com


-----Original Message-----
From: Ed Taekema [mailto:etaekema@earthlink.net]
Sent: Friday, April 23, 2004 8:27 PM
To: user@ant.apache.org
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:  http://www.pycs.net/users/0000177/stories/11.html .

Enjoy,

Ed Taekema
Toronto, Canada

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message