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 Fri, 20 Sep 2002 12:46:52 GMT
Rather than using myant.project, how about simply using 'project'.  Does 
that give you strange results too?

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>


Mime
View raw message