ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <mart...@apache.org>
Subject Properties getting unset with <import>?
Date Sat, 04 Dec 2004 19:39:48 GMT
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


Mime
View raw message