ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Hatcher <jakarta-...@ehatchersolutions.com>
Subject Re: The task's owning project accidently changed
Date Mon, 23 Sep 2002 15:11:04 GMT
Definitely looks like a bug.  Go ahead and add this to Bugzilla with all 
  your examples.

Thanks,
	Erik


Michael Zhou wrote:
>>Rather than using myant.project, how about simply using 'project'.  Does 
>>that give you strange results too?
> 
> 
> of course, not.  the build file i wrote is just an EXAMPLE to show you
> the bug(maybe?)  i want to show you that BEFORE and AFTER the ant task
> with inheritAll=yes, the getProject() of the reference "myant" has been
> changed accidently.  in another word, the "myant" task points to the
> wrong "parent" project after the excuting of  <ant antfile="b.xml" inheritRefs="true"/>.
> 
> 
>>Michael Zhou wrote:
>>
>>>Hi,
>>>
>>>Try the following build files:
>>>
>>>===== a.xml =======================
>>><project name="a" default="main">
>>>
>>>    <target name="main">
>>>
>>>        <script language="beanshell"><![CDATA[
>>>            print("before:  myant.project=" + myant.project.name);
>>>        ]]></script>
>>>
>>>        <ant antfile="b.xml" inheritRefs="true"/>
>>>
>>>        <script language="beanshell"><![CDATA[
>>>            print("after:   myant.project=" + myant.project.name);
>>>        ]]></script>
>>>
>>>        <ant id="myant" antfile="c.xml"/>
>>>
>>>    </target>
>>>
>>></project>
>>>
>>>===== b.xml =======================
>>>
>>><project name="b" default="main">
>>>    <target name="main"/>
>>></project>
>>>
>>>
>>>===== c.xml =======================
>>>
>>><project name="c" default="main">
>>>    <target name="main"/>
>>></project>
>>>
>>>
>>>===== RESULT OF [ant -f a.xml] =======================
>>>
>>>Buildfile: a.xml
>>>
>>>main:
>>>   [script] before:  myant.project=a
>>>   [script] after:   myant.project=b
>>>
>>>BUILD SUCCESSFUL
>>>
>>>Noticed that the owning project of "myant" task accidently changed after
>>>a calling of ant task with "inheritRefs" on.
>>>
>>>Because method copyReference() of class org.apache.tools.ant.taskdefs.Ant
>>>trying to clone the referenced object and set the new cloned object to
>>>new Project.  but the "Ant" is not clonable, so set calling
>>>Ant.setProject() causes the change of the original task.
>>>
>>>This causes some problem to me.  Anyone can help?
>>>
>>>tks.
>>
>>
>>--
>>To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
>>For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>>
> 


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


Mime
View raw message