Why Does Ant Do Bad Things to Good Developers?
If you are somewhat familiar with Java development and Ant, prepare to see the strangest thing you have seen in a long while. I can show you better than I can explain it. Check out this command:
$ jar tf wpGateway.war|grep ActDisplayAction WEB-INF/classes/com/workpoint/gateway/admin/framework/action/ActDisplayAction.class WEB-INF/classes/com/workpoint/gateway/admin/framework/action/ActDisplayAction.class
No, I didn’t doctor the output — I have a war file that contains mulitple instances of the same exact same class. Exact same file, in fact. This, naturally, happened on accident.
It took me a long time to figure out why, though. I was editing the source in Eclipse and then building with Ant outside of Eclipse. Eclipse was saving the class files under Webroot/WEB-INF/classes. When I used Ant to build the project, it compiled everything under the src directory to build/classes. But there are other files under Webroot that it needed to copy into the war, so the build file had it copy all the files under Webroot — including the class files that Eclipse placed there.
Now, this is wrong and the same classes should have never been done. But this also brings up questions to jar/war/ear files — I always thought they were just zip files with a well-place manifest put in the right place. This tells me that it is either something more sinister or that Ant really doesn’t know what it is doing when it is making a jar/war/ear file.
