What solutions exist for Ant/IDEA .jar packaging?

I have been wrestling with this problem for a while now.

I use IDEA to build my projects for local testing. I have written some pretty neat build scripts to allow Ant to do the same thing; this is in anticipation of having a separate build machine that will retrieve sources from CVS instead of having them locally available. So now both IDEA and Ant can build and test my software.

My problem comes in when projects are dependent on libraries, or other software that I've written. If it is my own software, and I need to make a change, I have to go change the library, which requires me to shut down the current instance of IDEA in order to NOT have problems after I've built new .jar files. So if I have a project P and a library L that I have both written, I need to close P before I make changes to L so that P will read the new .jar files for L when I reload it. Apparently IDEA will not swap .jar files once they are loaded. Usually this results in not recognizing any of L's classes if I remake L's .jar file with P still loaded. Should I instead unify my entire source tree and use ANT to make the appropriate .jar files when needed?

The other problem stems from deploying P. Let's say I'm using L, trove, log4j, and BeanShell. Currently, I point IDEA to look at the individual directories for all those packages using "Global" libraries, including for my own, L. I then go to the ANT build script properties and check off "Use project classpath" so that Ant gets the same libraries that IDEA does. Now, does this mean that my Ant build script will not run correctly separate from IDEA, since it depends on the IDEA project classpath?

What I also can't figure out is, how do I get ANT to then package my application, P, along with L, trove, log4j, and BeanShell? Am I forced to maintain a new .properties file that lists each library, and is Ant forced to copy them in during the creation of the final set of .jars in my "dist" directory?

Thanks for any help.

1 comment
Comment actions Permalink


I haven't had the problem you mention with new jars that a project must read with restarting(I work under windows with IDEA EAP and 3.0.5). In fact I have many libraries that i can re-build and what I usually do is have a latest/ directory i point to for picking up what ever the last build i made was. I usually use IDEAS named libraries and do not import jars one a t a time.... I don't know if this makes a diff.

About the Ant problem.... this is a tough one. I usually only package jars in a dist that I do not consider publically available. For example, where I work there are repositories for certain libraries that I know will be on any unix environment I run an app... and always in the same place. So need to package them.

Also to avoid ant scripting overhead I have developped a pretty generic build.xml that i use for allmost all my building situations.... writing a custom property file is all i ever write.

It does have the disadvantage of forcing me to keep my ant properties and the IDEA projects in sinch... but i make up for that with having little ant overhead.



Please sign in to leave a comment.