ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rick Genter" <>
Subject RE: Working directory confusion
Date Tue, 01 Feb 2005 18:09:30 GMT
The problem is not with ${basedir} but with the CWD. I've modified my
original example to use <subant> to illustrate the problem:

File test.xml:
<?xml version="1.0"?>
<project name="test" default="all">
	<target name="all" depends="sub1"/>
	<target name="sub1">
		<delete dir="sub1"/>
		<mkdir dir="sub1"/>
		<echo>Calling sub1-test via &lt;subant&gt; task:</echo>
		<subant genericantfile="test.xml" target="sub1-test">
			<dirset dir="${basedir}" includes="sub1"/>
		<copy todir="sub1" file="test.xml"/>
		<echo>Calling sub1-test via ant.bat:</echo>
		<exec executable="cmd.exe"
			<arg value="/c"/>
			<arg value="call"/>
			<arg value="ant.bat"/>
			<arg value="-buildfile"/>
			<arg value="test.xml"/>
			<arg value="sub1-test"/>
	<target name="sub1-test">
		<echo>My basedir is ${basedir}.</echo>
		<echo>My current directory is ${user.dir}.</echo>

The <subant> task echoes

My basedir is C:\workspace-4\Object\sub1.
My current directory is C:\workspace-4\Object.

The current directory is not changed, though the basedir is. I've tried
through <subant> and <ant>; neither change the CWD. I guess in a way
that makes since if no new process is created, but it's annoying. The
only way to do what I want is to use <exec>, which is painful.
Rick Genter
Principal Engineer
Silverlink Communications
(781) 272-3080 x242

-----Original Message-----
From: Dominique Devienne [] 
Sent: Tuesday, February 01, 2005 12:53 PM
To: Ant Users List
Subject: RE: Working directory confusion

> From: Rick Genter []
> No, the basedir was correct, but the cwd wasn't.
> For each test case I copy the jars required by that test case as well
> its test data into the test case's subdirectory. This allows each test
> case to be a self-contained unit if I need to pull it out for further
> analysis or send it to someone or whatever. What that means, though,
> that I want to define a classpath like this:
> <path id="exec.class.path">
>   <pathelement location="./Test.jar"/>
>   <pathelement location="./Object.jar"/>
>   <pathelement location="./Messaging.jar"/>
>   ...
> </path>
> where "." is the test directory. I then do:

Actually, in a location attribute, "." is not cwd, it's always
${basedir}, so since you say the basedir is correct, the pb might be

Where is <path id="exec.class.path"> defined? In the genericantfile?
Is genericantfile the same build file as the one making the <subant>

I can't be sure of course, but it sounds like the issue is centered on
which build file create the path, and what is that build file's basedir
when it does create it. --DD

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

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

View raw message