tags:

views:

919

answers:

4

I like Eclipse's build path features, but would like to keep it in sync with my ant build.xml. Is there a way to either automatically import the Eclipse build path from a text file, or export the Eclipse build path to a text file, so I can use that file from ant? (if I can get to a text file, I know I can figure out how to get ant to use that file as its javac build path)

+5  A: 
VonC
We are using it with our Hudson builds. It took quite a bit of elbow grease to come from the configuration to functional code, as we have multi-project applications.
Thorbjørn Ravn Andersen
+4  A: 

Is there a way to either automatically import the Eclipse build path from a text file, or export the Eclipse build path to a text file, so I can use that file from ant?

The Eclipse build path already is a text file (.classpath):

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
  <classpathentry kind="src" path="src"/>
  <classpathentry kind="lib" path="lib/ojdbc14_g.jar"/>
  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
  <classpathentry kind="output" path="classes"/>
</classpath>
rodrigoap
oh, sweet -- so that's what that .classpath file is for! (duh, can't believe i never really looked at it)
Jason S
A: 

Just put all your jars in a well known location and in the ant build just add all those jars.

Then configure eclipse specifically in terms of the jars it requires. I want eclipse to be specific about the jars it requires, because I'm concerned about compile time, but with ant it's less of a concern - it's normally a fire and forget build.

Michael Wiles
This approach scales badly (just imagine how to handle multiple versions of the same jar, updates, etc) and was why Maven was created.
Thorbjørn Ravn Andersen
+1  A: 

Starting with Eclipse 3.4 (I think) you can "export" a project into ant files. Choose "Export..." by right clicking on a project. Under "General" is "Ant Buildfiles". It generates an ant file that you could use to recompile the entire project.

Jeff Walker