You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Melih Onvural <me...@gmail.com> on 2009/09/26 04:24:52 UTC

behavior on properties... is it a bug? or by design?

I noticed that when I run targets in a <foreach> loop, that they don't
know of properties that were set in previous targets or in targets
which
are dependencies of the given target. As an example:

<foreach target="getcssfiles" param="localedir">
     <path>
          <dirset dir="${project.dir}/santiago/locale" includes="*/**"
excludes="*Apple*"></dirset>
     </path>
</foreach>

in target with name of getcssfiles, I don't know what my build number
is. However, if I add a param to the <foreach> loop, then I can pass
through
whatever properties I want, and they are available to the target in
the <foreach> loop.

e.g. this works:

<foreach target="getcssfiles" param="localedir">
     <param name="build.num" value="${build.num}" />
     <path>
          <dirset dir="${project.dir}/santiago/locale" includes="*/**"
excludes="*Apple*"></dirset>
     </path>
</foreach>

Is not inheriting properties in a <foreach> loop by design? It feels
like a bug to me, but I didn't want to log it as a bug until I was
sure that it really
was one.

Thanks,
-- 
Melih Onvural
http://www.onvural.net/melih

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


Re: behavior on properties... is it a bug? or by design?

Posted by cvsusr <sp...@rediffmail.com>.
Did you loop through targets using for loop?? If so, please let me know some
example.

Thanks.


Melih Onvural wrote:
> 
> Thanks a bunch for that!
> 
> --
> Melih
> 
> On Sep 25, 2009, at 8:44 PM, Dominique Devienne wrote:
> 
>> On Fri, Sep 25, 2009 at 9:24 PM, Melih Onvural <melih.onvural@gmail.com 
>> > wrote:
>>> I noticed that when I run targets in a <foreach> loop, that they  
>>> don't
>>> know of properties that were set in previous targets or in targets
>>> which are dependencies of the given target. As an example:
>>
>> Yep, by design. <foreach> uses a different Project for each iteration,
>> just like <ant>, <antcall>, and <subant>. You want to use Ant- 
>> Contrib's
>> <for> task instead, and is newer and better. --DD
>>
>> ---------------------------------------------------------------------
>> 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
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/%3Cforeach%3E-behavior-on-properties...-is-it-a-bug--or-by-design--tp25621716p26285979.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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


Re: behavior on properties... is it a bug? or by design?

Posted by Melih Önvural <me...@gmail.com>.
Thanks a bunch for that!

--
Melih

On Sep 25, 2009, at 8:44 PM, Dominique Devienne wrote:

> On Fri, Sep 25, 2009 at 9:24 PM, Melih Onvural <melih.onvural@gmail.com 
> > wrote:
>> I noticed that when I run targets in a <foreach> loop, that they  
>> don't
>> know of properties that were set in previous targets or in targets
>> which are dependencies of the given target. As an example:
>
> Yep, by design. <foreach> uses a different Project for each iteration,
> just like <ant>, <antcall>, and <subant>. You want to use Ant- 
> Contrib's
> <for> task instead, and is newer and better. --DD
>
> ---------------------------------------------------------------------
> 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


Re: behavior on properties... is it a bug? or by design?

Posted by Dominique Devienne <dd...@gmail.com>.
On Fri, Sep 25, 2009 at 9:24 PM, Melih Onvural <me...@gmail.com> wrote:
> I noticed that when I run targets in a <foreach> loop, that they don't
> know of properties that were set in previous targets or in targets
> which are dependencies of the given target. As an example:

Yep, by design. <foreach> uses a different Project for each iteration,
just like <ant>, <antcall>, and <subant>. You want to use Ant-Contrib's
<for> task instead, and is newer and better. --DD

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