How do I set the Eclipse build path and class path from an Ant build file?

Posted by Nels Beckman on Stack Overflow See other posts from Stack Overflow or by Nels Beckman
Published on 2010-03-08T19:48:21Z Indexed on 2010/03/08 19:51 UTC
Read the original article Hit count: 252

Filed under:
|
|
|
|

Hey folks,

There's a lot of discussion about Ant and Eclipse, but no previously answered seems to help me.

Here's the deal: I am trying to build a Java program that compiles successfully with Ant from the command-line. (To confuse matters further, the program I am attempting to compile is Ant itself.)

What I really want to do is to bring this project into Eclipse and have it compile in Eclipse such that the type bindings and variable bindings (nomenclature from Eclipse JDT) are correctly resolved. I need this because I need to run a static analysis on the code that is built on top of Eclipse JDT. The normal way I bring a Java project into Eclipse so that Eclipse will build it and resolve all the bindings is to just import the source directories into a Java project, and then tell it to use the src/main/ directory as a "source directory."

Unfortunately, doing that with Ant causes the build to fail with numerous compile errors. It seems to me that the Ant build file is setting up the class path and build path correctly (possibly by excluding certain source files) and Eclipse does not have this information.

Is there any way to take the class path & build path information embedded in an Ant build file, and given that information to Eclipse to put in its .project and .classpath files? I've tried, creating a new project from an existing build file (an option in the File menu) but this does not help. The project still has the same compile errors.

Thanks, Nels

© Stack Overflow or respective owner

Related posts about ant

Related posts about eclipse