You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bu...@apache.org on 2005/05/02 10:09:24 UTC

DO NOT REPLY [Bug 30569] - basedir is not set correctly when calling subant task through ant task

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=30569>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=30569





------- Additional Comments From StefanHansel@web.de  2005-05-02 10:09 -------
Created an attachment (id=14894)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=14894&action=view)
Testcase for the Bug

Today I'm facing the same problem, described here.

When "antcall" calls a target that contains "subant" the basedir of alle
targets called by subant are wrong.
I could not find a workaround.

Since I already built a a small testcase, I will attach it: 

To reproduce, please create following folder structure (see attachment)

P1\build.xml
P2\build.xml
master\build.xml
helper\helper.xml


helper.xml is a small file, containing our subant-task, it needs a property
"depend" to be set: 

----------------
<?xml version="1.0"?>

<project name="helper" default="dependencies">
	<target name="dependencies">
		<echo message="subproject basedir=${basedir}" />
		<subant antfile="build.xml" target="message" inheritAll="false"
inheritRefs="false">
			<dirset refid="depend" />
		</subant>
	</target>
</project>
--------------------

files P1\build.xml and P2\build.xml just echo their basedir:

--------------------
<?xml version="1.0"?>

<project name="p1" default="message">
	<target name="message">
		<echo message="file=${ant.file}" />		
		<echo message="mybasedir=${basedir}" /> 	
	</target>
</project>
--------------------


Our master build-file calls a target from helper.xml via antcall.
In target "run1" it explicitly sets the dir-property, while in "run2" we just
leave it open, so helper.xml will set 
its own basedir.

-----------------
<?xml version="1.0"?>

<project name="master" default="run">
	<property name="project.name" Value="${ant.project.name}" />

	<dirset id="depend" dir=".." includes="." >
		<include name="p1" />
		<include name="p2" />		
	</dirset>
	
	<target name="run1"> 
		<ant antfile="../helper/helper.xml" target="dependencies" 
inheritrefs="no" inheritall="no" dir="${basedir}">
			<reference refid="depend" />
		</ant>
	</target>	

	<target name="run2"> 
		<ant antfile="../helper/helper.xml" target="dependencies" 
inheritrefs="no" inheritall="no">
			<reference refid="depend" />
		</ant>
	</target>	
</project>
---------------------



The output of "run1" is the following, you can see, that P1/build.xml and
P2/build.xml don't have their own basedir, but all work
in the dir of the master-script:

----------------
C:\temp\master>ant run1
Buildfile: build.xml

run:

dependencies:
     [echo] subproject basedir=C:\$user\temp\ant\master

message:
     [echo] file=C:\$user\temp\ant\p1\build.xml
     [echo] mybasedir=C:\$user\temp\ant\master

message:
     [echo] file=C:\$user\temp\ant\p2\build.xml
     [echo] mybasedir=C:\$user\temp\ant\master

------------------------


For "run2" you get the following output.
Note that the subproject now works in its own directory (helper), while the
projects called by subant work in 
their own directory (which is the supposed behaviour)

-------------------------
C:\temp\master>ant run2
Buildfile: build.xml

run2:

dependencies:
     [echo] subproject basedir=C:\$user\temp\ant\helper

message:
     [echo] file=C:\$user\temp\ant\p1\build.xml
     [echo] mybasedir=C:\$user\temp\ant\p1

message:
     [echo] file=C:\$user\temp\ant\p2\build.xml
     [echo] mybasedir=C:\$user\temp\ant\p2
-------------------------

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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