Using your Eclipse .classpath files from build.xml
by Kevin Dangoor
Some nameless person says that you should JavaGu(i)(y): Stop adding Eclipse .classpath and .project files to cvs!. Most of the comments in reply to this say that you should check those files in and use Eclipse’s mechanisms for dealing with variations (classpath variables and the like).
I agree that you should check these files in. We’ve gone even farther than that. Our ant build.xml file has a little piece of Groovy script that reads the .classpath file to set the classpath for the build. That way, we only have one classpath (Eclipse’s) to maintain. We also generate a JNLP file from the .classpath. This setup works great for us. Eclipse works easily when you check the project out, and our Solaris build server running anthill can run the builds without worrying about syncing up the classpaths.
I presume that everybody must use Eclipse then
Well, generally, IDE’s are standardized in companies. Plus, it lets you know what the dependencies are in a project.
I’d be interested in seeing that groovy script you were using..
we got this problem and am really interested to see the groovy script……..
ravi
there is a plug in that allows ant scripts to use classpath entries from your eclipse .classpath. have a look at joey gibson’s blog — he’s the author.
The URL for my plugin is http://www.joeygibson.com/blog/tech/java/Ant/EclipseClasspathTask.html
Well, I for one disagree with this. Assuming you are always guaranteed to be using the same IDE forever, which is never a guarantee, I still dont know that I would want this.
To me, making the build process dependent on the IDE in use is like making your application dependent on the OS it runs on, namely a single OS. Sometimes this may actually be necessary, although I haven’t seen any reason to do this.
I can see the merit in using a single classpath, I just don’t know that maintaining a classpath is all that hard. I mean, if you set up a project directory structure in a nice neat fashion, most of the time you should be able to put all your 3rd party libraries within the /lib directory and use a simple fileset to include them all. No doubt there are more complex setups out there so that may not hold water all the time.
An useful Eclipse advise.
Martin van den Bemt complaining about Eclipse project files (.project and .classpath) committed to CVS. I can see his point, however he should blame those people who are using absolute paths to external jars in those files. I alway put Eclipse project i