ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Cooper <>
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 

<project name="imported" basedir=".">
   <target name="init">
     <property name="foo" value="foo-value"/>
     <echo message="foo is set"/>
   <target name="show" depends="init">
     <echo message="foo = ${foo}"/>

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

Now if I do:

ant -f importer.xml show

I get:


      [echo] foo is set

      [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:

      [echo] foo is set

      [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. ;-}


Martin Cooper

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message