Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!postnews.google.com!cf6g2000vbb.googlegroups.com!not-for-mail From: www Newsgroups: comp.lang.java.programmer Subject: Re: One Ant buildfile calling its subdir buildfile, how to change the base dir? Date: Wed, 11 Jan 2012 12:00:45 -0800 (PST) Organization: http://groups.google.com Lines: 57 Message-ID: <4f3ee79e-e431-4224-a08f-973b8223aaa6@cf6g2000vbb.googlegroups.com> References: NNTP-Posting-Host: 205.156.36.56 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1326312045 2458 127.0.0.1 (11 Jan 2012 20:00:45 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 11 Jan 2012 20:00:45 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: cf6g2000vbb.googlegroups.com; posting-host=205.156.36.56; posting-account=oo44OQoAAABMDvaRlaO3SeQ5MVbxqLdH User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1,gzip(gfe) Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11240 After some investigation, I would like to re-phrase my question. Here are my files: main/build.xml containing a target invoking a target in sub directory main/sub/build.xml --> containing a target "MyTest" running a JUnit test -- calling A.B.C.MyTest class Inside MyTest.java, I added this print out: final String currentDir = new File(".").getAbsolutePath(); System.out.println("currentDir=" + currentDir); Running the target MyTest at main/sub is *fine*, with these printout: [echo] sub base dir=/xxx/xx/main/sub MyTest: [junit] currentDir=/xxx/xx/main/sub/. <------The printout in MyTest shows that it is run at main/sub, so inside MyTest, a relative path is correct Running the target test-sub at main is *bad*, with these printout: test-sub: [echo] main base dir=/xxx/xx/main [echo] sub base dir=/xxx/xx/main/sub/. <--- the echo from sub/ build.xml shows that the base dir is already main/sub, not main/, however, MyTest is still run at main/, not main/sub MyTest: [junit] currentDir=/xxx/xx/main/. <------The printout in MyTest shows that it is still be run at main/, not main/sub, so inside MyTest, a relative path becomes invalid Thank you very much.