ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <h...@visi.com>
Subject Re: Properties getting unset with <import>?
Date Sun, 05 Dec 2004 03:11:36 GMT

You should have expected this because you are using <antcall>.  It creates 
a new Ant project which is discarded after the call returns.  I think what 
you meant to do is...

<project name="importer" basedir=".">
   <import file="imported.xml"/>
   <target name="init" depends="imported.init"/>
</project>

That should work as expected.

Jake

At 11:39 AM 12/4/2004 -0800, you wrote:
 >This is weird. I'm using Ant 1.6.2, and trying to use <import> with
 >selective overriding of targets. The problem is that when I invoke an
 >imported target from its override, any properties set in that target
 >appear to be "forgotten" later on. An example will make this clear, I
 >hope.
 >
 ><project name="imported" basedir=".">
 >   <target name="init">
 >     <property name="foo" value="foo-value"/>
 >     <echo message="foo is set"/>
 >   </target>
 >   <target name="show" depends="init">
 >     <echo message="foo = ${foo}"/>
 >   </target>
 ></project>
 >
 ><project name="importer" basedir=".">
 >   <import file="imported.xml"/>
 >   <target name="init">
 >       <antcall target="imported.init"/>
 >   </target>
 ></project>
 >
 >Now if I do:
 >
 >ant -f importer.xml show
 >
 >I get:
 >
 >init:
 >
 >imported.init:
 >      [echo] foo is set
 >
 >show:
 >      [echo] foo = ${foo}
 >
 >The property has been forgotten? This is clearly not what I would expect!
 >
 >Now, if I remove the overridden 'init' target, I get:
 >
 >init:
 >      [echo] foo is set
 >
 >show:
 >      [echo] foo = foo-value
 >
 >which is what I expect.
 >
 >Is this a known bug? Or is there something I'm doing wrong? If it's a bug,
 >is there a workaround? I can't really do much with <import> when my
 >properties get forgotten. ;-}
 >
 >TIA.
 >
 >--
 >Martin Cooper
 >
 >
 >---------------------------------------------------------------------
 >To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
 >For additional commands, e-mail: user-help@ant.apache.org
 >
 >  


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


Mime
View raw message