开发者

New to Ant - Problem with relative paths

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜