 |
Running ant in loop mode
Posted by felipeal on September 02, 2003 at 09:31 AM | Comments (9)
Once in a while I work in a Java project where I need to run a simple Ant task many times in a short period of time. Like web projects where the JSP files are located in a directory under source control and are deployed in another directory by an Ant task. If I change a JSP file, I need to run Ant again, and it takes an eternity (about 5-6 seconds), due to the overhead of running the JVM, reading the XML files, etc...
Wouldn't it be nice if I could leave Ant running in a loop mode in those situations, so when I change the file I could redeploy it without that overhead?
For me, the answer is "Yes, that would be nice". But Ant doesn't have that feature, so now what? Now I can change Ant to include that feature, and that is the beauty of open source projects: if you want a new feature, you can just grab the code and implement it yourself. The same with bugs: rather than wait for the vendor to fix, test and publish a patch, you can open the code and nail the bug!
Now back to that new Ant feature: I created such patch and opened a bug for it.
We've been using it for a while in my team, and so far it's working fine. It's not in the basecode of Ant yet - and it might never be - so I upload the code to my site. If you liked the idea, please feel free to download it and give it a try. And if you like the results, give me some feedback through the bug's page or this weblog.
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
ANT Shell
Hi Felipe, really sometimes we need some way to invoke several times the JVM in a short time, your view and patch seems good. Well, I found a project called ANT Shell (tha name says by itself) - http://rhinohide.cx/antsh, it looks good too.
Posted by: claudio on September 03, 2003 at 05:33 AM
-
ANT Shell
Hi Cláudio,
Thanks for the link, I din't know that project. Looks like it provides a full console for Ant, and that it's interesting too ( I heard Maven offers that by default too).
The main idea of my patch is to provide a simple - yet useful - feature for those that run Ant straight from the command line. It wouldn't make much sense, for instance, inside an IDE.
Finally, the inspiration for the patch comes from Jikes, which have an option for progressive compilation.
Posted by: felipeal on September 03, 2003 at 05:54 AM
-
ForEach
I take it that ForEach did not fit the job?
I used it to look over files, lists etc and call a seperate ant file for each. Pretty powerful, and covers most uses.
Posted by: zander on September 06, 2003 at 09:44 AM
-
ForEach
I don't think forEach would fit in this case, as you still need to modify your rules to use it (ant the patch is just a change on the command line interface for ant, not in the tasks itself).
Anyway, that forEach task is useful too - although the developers are reluctant to include this kind of task on Ant, as they don't want it to become a scripting language.
Posted by: felipeal on September 07, 2003 at 02:51 PM
-
Batch file
Why don't you just write a batch file calling ant in a loop? It should provide the funcionality you want, and wouldn't violate Ant's philosophy of not incorporating flow control in its build-script.
They simply don't want Ant to became... Python (or the scripting prog. lang. of your choice). It's not a programming language. Incorporating such things would lead people to build whole applications on top of Ant scripts... (you know some people DO like to do those kind of things...) and it would be the chaos! :-)
Posted by: ronaldtm on September 08, 2003 at 04:49 AM
-
Batch file
Why don't you just write a batch file calling ant in a loop? It should provide the funcionality you want,
Running Ant in a shell script (or batch) file wouldn't help, because every iteration would require a new invocation of the JVM, and that's where the patch is useful (i.e., it runs the iteration inside the JVM running ant).
and wouldn't violate Ant's philosophy of not incorporating flow control in its build-script.
I disagree in this point too. The patch is just for Ant's CLI (command-line interface), it's not adding a new task with flow-control behaviour.
Posted by: felipeal on September 08, 2003 at 05:51 AM
-
ANT Shell
Some time in the past few months I saw an article about an ant extension that ran a server which loaded and cached the build file. you could then use a simple client to tell the server to run a certain target.
I can't find the article again, but I did come across the following while looking:
http://www.sdv.fr/pages/casa//html/sat.doc.en.html#3
which has an Ant Console, allowing you to reload the build file, run targets etc. It may give the speedups you are looking for?
Has anyone else seen the article I can't find, or did I imagine it?
Posted by: currane on September 08, 2003 at 09:05 AM
-
Emacs + JDE has an ant-server
I never used it myself and found very little documentation despite this about it, but I heard that JDE keeps a JVM with ant in memory all the time, so at least the eternity to start the VM and load all the neccesary classes is nullified.
Posted by: konz on September 08, 2003 at 12:24 PM
-
Emacs + JDE has an ant-server
Hi,
I use JDEE sometimes (not as much as I'd like to :). I'm not sure if it keeps a JVM open all the time, but it uses BeanShell to compile and run your classes. So, the first time you try to compile a buffer, it will be slow, as BeanShell is being instatiated. But the next compilations will be really fast.
I'm not sure if integrates with Ant though - it should, but I have never tried (in fact, threre are many JDEE features that I don't use).
Felipe
Posted by: felipeal on September 08, 2003 at 06:06 PM
|