Information about the Eclipse build path is stored in a .classpath file, and you can possibly parse simple bits from this (entries that point to individual JAR files either in the project workspace or externally with absolute paths), but you will only get this so far - there are other types of entries in the classpath, such as those based on "classpath variables", links to other projects in the workspace, or to other types of containers provided by the Eclipse plugins. For example, I have GGTS plugins (for Groovy and Grails), and my Grails .classpath project .classpath not have explicit JARs, it just says
<classpathentry kind="con" path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
There is an Ant4Eclipse project that claims to help with this, but the most recent version (“milestone 4”) is from mid-2010, and I don’t know how well it works with later eclipses.
An improved approach could be to declaratively manage your dependencies using Ivy and have both an Ant construct and an Eclipse project (using IvyDE ), from which their libraries are taken. When you want to add or remove a dependency, you simply edit the ivy.xml file, and both Ant and Eclipse will pick up the changes in the next build.
source share