export/import Eclipse build path

19,466

Solution 1

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>

Solution 2

Maybe ant4eclipse is the tool (plugin) you need.

alt text
(source: sourceforge.net)

The aim of the ant4eclipse project is to avoid (or at least: to reduce) the redundancy of Eclipse and Ant configurations.
More precisely: it consists of Ant tasks that are able to read and work with some of Eclipse's configuration files. With these tasks you're able to:

  • Setup classpathes as defined in Eclipse' .classpath-file
  • checkout complete workspaces as it's possible with the Team Project Set feature of eclipse
  • run your Java applications as you have defined them in an Eclipse Launch Configuration

With all these tasks you're able to create a complete automatic build system that starts with checking out all required projects from CVS, builds all projects in the correct order with classpath settings as specified in Eclipse, and to launch your applications as they are specified in Eclipse.
And the best of it: if you or someone else changes a configuration in Eclipse, those changes are immediately visible to your buildfiles - without changing one line of code!

Solution 3

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.

Share:
19,466
Jason S
Author by

Jason S

Updated on June 09, 2022

Comments

  • Jason S
    Jason S almost 2 years

    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)