Eclipse 2.1 & Ant: Beware!
Matt Croydon
href="http://postneo.com/2003/04/23.html#a2439">mentioned tonight that
he is downloading Eclipse 2.1.
Seeing his post on the subject reminded me of something I had intended to
mention in my own
href="http://www.scifihifi.com/weblog/software/Eclipse.html">review of
Eclipse a few days ago—that the version of Ant bundled with 2.1 is seriously, frustratingly broken.
I discovered this the hard way: after several days of banging my head against the wall and (literally) throwing things at my computer (the Sony VAIO at work, of course, not my beloved PowerBook) because Ant was behaving in ways that simply defied logic.
It all began after I upgraded to Eclipse 2.1 and then started a new project. Since the project was a web application, I began by putting together an Ant build file to automatically assemble its EJB-JAR, WAR, and EAR files. I was using very standard Ant code—mostly along these lines (Update: I originally had this code inline, but it was screwing up my RSS feed in NetNewsWire).
This code should, of course, produce a file called “test.jar” containing “META-INF/test.txt”. For me, however, it was creating nothing but empty Jars.
After several days of trying to figure out what the Apache people had changed to rendered my code ineffective, I finally decided it must be a bug in Ant. And I was right.
As the above referenced bug report suggests, the problem was fixed in the 1.5.3 release of Ant, and fortunately it is fairly straightforward to patch in Eclipse. The following worked well for me:
- Download Ant 1.5.3.
- Copy the contents of plugins/org.apache.ant_1.5.2 to plugins/org.apache.ant_1.5.3.
- Replace ant.jar and optional.jar at plugins/org.apache.ant_1.5.3 with the Jars from the newer distribution.
- Change the version number in plugins/org.apache.ant_1.5.3/plugin.xml to 1.5.3.
- Trash plugins/org.apache.ant_1.5.2.
After making that adjustment, my build file finally worked properly. And not a moment too soon—I was beginning to think I was just thick!
Just wanted to get that information out in an attempt to (hopefully) spare Matt and others from the same frustration I endured!