views:

394

answers:

6

I'd be interested to find out about any automated processes that people have for ensuring that the project classpaths for the ant and eclipse configurations are in synch. In my case, I want the classpath defined in the ant build file to be the master configuration, since its used for our production builds. As part of the build i'd like to add an ant target that will verify that the eclipse classpath is up to date, or at least indicate differences between the two classpaths.

I'm aware of ant4eclipse but its focus is in the opposite direction, ensuring that the eclipse classpath is master and that the ant build reuses the eclipse path. I like the idea behind AntAndEclipse but am wondering are their ant other tools in this space that i'm not aware of.

A: 

I'm not aware of any ant tools which can do this but I've switched from ant to Maven a few years ago and never looked back. You can use the "Maven integration for Eclipse" to make Eclipse use the Maven classpath.

As of today, I'm not 100% happy with the Eclipse plugin, though. It's a bit slow and due to the different philosophy of Eclipse and Maven, some operations behave strange. For example, Eclipse doesn't differentiate between a "production" and "test" classpath, so you can get compile errors in Maven when everything looks great in Eclipse.

My solution was to use the plugin to keep the classpath in sync and compile from the commandline.

Aaron Digulla
+1  A: 

You solution at a previous company was to have ant invoke Eclipse to do the compiles as described here:

http://www.eclipse.org/articles/Article-PDE-Automation/automation.html

Jeffrey Fredrick
The OP didn't mention he was doing plug-ins, so can you use headless PDE for vanilla Java? And headless PDE is one big pile of crap - it's difficult to get working and the error reporting is poor when something goes wrong with the build process (not the simple java compilation errors).
hbunny
A: 

there is an ant task to do xml transformations, we used that task to create the classpath in our build file. It was a little trick to get the XSL right but once it worked it was great

Aaron Saunders
A: 

Did you evaluate Apache IVY? Currently I am building a Continuous Integration environment at our place and we use IVY to handle our dependencies. There is a eclipse plugin that takes the dependency configuration of eclipse and uses it as eclipse classpath. Currently this solution looks quite promising.

Tobias Hilka
It's worth mentioning that IVY has tight integration with ANT.
hbunny
A: 

My team wrote an Eclipse plug-in to add a new type of library to the Java Build Path->Add Library option in the project settings. This custom library type allowed both Eclipse and ANT to reference the same canonical list of dependencies.

Nowadays, I'd probably look at IVY for doing the same thing if I was locked into using ANT, rather than writing my own.

hbunny
A: 

You need Ant2Eclipse.

neves