ant-user mailing list archives

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

I need to start ANT from one OSGi Bundle in concurrent mode. The build 
xml files are passed as parameters to startAnt method of 
org.apache.tools.ant.Main.
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 java.io.File 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.


Regards,
Miro.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message