views:

160

answers:

4

I'm having problems building my project, using an Ant script, from the command prompt using Ant itself. It can't find a certain import for a particular Java file in my project (which has nearly 5,000 source files as it is). The import is included in a .jar package whose location I have set in the Ant file itself. Oddly enough, I can build the project just fine from the Ant file using an IDE like Eclipse. Any ideas what could be wrong? Thanks!

A: 

check the basedir property. If the location of the jar in question is relative then the basedir will influence the behaviour in this peculiar way.

Or it could be that eclipse adds that jar to the classpath when it will run the ant file.

Convert the jar location to an absolute path

<property name="x" location="${jar.reference}" />

and print it

<echo message="${x}" />

My ant skills are a little rusty so you should double check the syntax :-).

Toader Mihai Claudiu
Doesn't seem to be the classpath. It echoed correctly.
Monster
A: 

Can you tell us the name of the jar? Whenever I've had this issue it has always been to do with versions of libraries used by the IDE but not in the ANT_HOME/lib directory, usually logging or xml parsing.

Which ant command is failing? java/javac? Have you tried using the fork=yes option if it is java?

Nick Fortescue
It's a third party JAR file with the correct version needed, as part of the project distribution by my company.Javac is failing though, and yep, fork is on.
Monster
A: 

Have you defined properly your classpath in Ant ? Eclipse tends to automatically compute the classpath when running ant...

Valentin Rocher
Yep, I'm using a class path file (.classpath), and everything there is correct
Monster
A: 

Any other suggestions? :/

Monster