ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miroslav Nachev <>
Subject How to set Current Working Directory (CWD) from Java application
Date Wed, 03 Sep 2008 13:46:26 GMT

I need to start ANT from one OSGi Bundle in concurrent mode. The build 
xml files are passed as parameters to startAnt method of
The first problem in that approach is that the current working directory 
(System.getProperty("user.dir")) must be different for each startAnt 
call. I need of that because the base directory in XML file in most of 
the cases is set relatively like ".", "..", "../x", etc.
The second problem is when I set the CWD using 
System.getProperties().put("user.dir", newBaseDir) the File instance use 
the original CWD instead of the new value.

Do you have any idea how can I solve that? The smart way is if ANT 
implementation have helper method for CWD like 
getCurrentWorkingDirectory(). To solve the File problem new AntFile 
class which extends can be used. Then this new AntFile 
class will check in the constructors for strings which starts with "." 
or ".." and will replace the value with instance CWD.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message