views:

184

answers:

1

Please help, I'm going slightly mad!!

I'm using Eclipse-generated antfiles to build a project with dependencies, one of which has its own buildfile in a directory which is a sibling to the direct ancestor of the project I'm building. E.g. if my directory is "/base/modules/clinicalcontext", the directory of one of the dependencies is simply "/base/core".

So, the generated build.xml uses ../../core which afaik is correct. But it is not!! From the console it is apparent that Ant goes back three levels and not just two (it gives FileNotFound on "/core/build.xml").

I tried to change the relative path to "../core" and much to my astonishment, this way Ant goes back by one level (it laments "/base/modules/core" being nonexistent). So how in the world I tell Ant t go back by two levels? I'd prefer to avoid using absolute paths, since I might have to move the project to a different machine someday.

Thanks everybody.

+1  A: 

All Ant path will be relative to your current working directory.

So, check what directory you are running your script from.

I suggest that you start using ${basedir} to get a path relative to a location of build.xml.

In your case, the relative path should be constructed like this: ${basedir}/../../core, instead of ../../core.

The inconsistencies you encounter illustrate a point why eclipse-generated ant scripts are a good starting point, but never a good project build system.

EDIT. I wonder why eclipse ant generator does not insert ${basedir} in relative paths? Maybe you should report it as a bug.

Alexander Pogrebnyak
${basedir} is correctly set to . which is also the location of the buildfile I'm using.
Silma
Yes, but the path like this ( `../../core` ) is not relative to a basedir. `../../core` is dependent on your CWD, `${basedir}/../../core` is not.
Alexander Pogrebnyak
That did it, thanks! I didn't consider that buildfiles of dependencies would not change the CWD.
Silma