ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edgar "Sánchez" <vesanc...@yahoo.com>
Subject Re: Making Jumps or doing Loops!!
Date Thu, 23 Aug 2001 21:06:39 GMT
  Thank you Diane, and all you guys

--- Diane Holt <holtdl@yahoo.com> wrote:
> And of course, right after I send it again, I
> realize there's a d'oh! in
> it -- the "doit" target actually does run 10 times,
> not 9 (my parenthetic
> about it not being zero-based is completely wrong,
> since of course it is
> zero-based, so 9 is the last number that gets echoed
> out -- d'oh! :)
> 
> Diane
> 
> --- Diane Holt <holtdl@yahoo.com> wrote:
> > [Sorry if this ends up getting posted twice, but
> it was the first one I
> > sent, and I've yet to see it come through, so I'm
> not sure if it really
> > went out.]
> > 
> > Actually, I'd take advantage of some of the new
> stuff available in 1.4
> > (finally found some time to pick it up and start
> trying things out :) --
> > namely, the new "inheritAll" attr for <antcall>
> and the new <condition>
> > task, in conjunction with <propertyfile>'s
> incrementing functionality.
> > For
> > example:
> > 
> >   <property name="maxCount" value="10"/>
> > 
> >   <target name="doWhile">
> >     <propertyfile file="counter.properties">
> >       <entry key="counter" type="int"
> operation="+"/>
> >     </propertyfile>
> >     <property file="counter.properties"/>
> >     <condition property="loopDone">
> >       <equals arg1="${counter}"
> arg2="${maxCount}"/>
> >     </condition>
> >     <antcall target="doit"/>
> >   </target>
> > 
> >   <target name="doit" unless="loopDone">
> >     <echo message="Do stuff here..."/>
> >     <antcall target="doWhile" inheritAll="no"/>
> >   </target>
> > 
> > will "Do stuff here" 9 times (it's not zero-based
> :)  [Note: Make sure
> > something removes counter.properties before the
> "doit" target gets run.]
> > 
> > Diane
> > 
> > --- Don Taylor <donald_l_taylor_jr@yahoo.com>
> wrote:
> > > 
> > > --- Edgar Sánchez <vesanchez@yahoo.com> wrote:
> > > >   Thanks Don
> > > > 
> > > >     just a question.
> > > >    When you put the sample of the counter the
> "."
> > > > after the counter means that the value will
> increment
> > > > in one??
> > > 
> > > Not the value, the property name. I'm creating a
> series of properties:
> > > 
> > > counter
> > > counter.
> > > counter..
> > > counter...
> > > 
> > > The value is whatever.
> > > 
> > > -- Don
> > > 
> > > >    <property name="${counter}."
> value="whatever" />
> > > >   or how do I increment in one the variable
> value of
> > > > my counter?
> > > > 
> > > >   Thanks again
> > > > VES
> > > > 
> > > > 
> > > > --- Don Taylor <donald_l_taylor_jr@yahoo.com>
> wrote:
> > > > > 
> > > > > --- Edgar Sánchez <vesanchez@yahoo.com>
> wrote:
> > > > > >   Hi everyone is Vincent again...
> > > > > > 
> > > > > >     now I've 2 questions, well those are
> for the
> > > > > same
> > > > > > reason..
> > > > > >   I was wondering if here in Ant could I
> make some
> > > > > > jumps in order to repeat the same
> procedure with
> > > > > other
> > > > > > caracteristics, 
> > > > > 
> > > > > Yes, check out the antcall task. This allows
> you to
> > > > > execute the
> > > > > same target multiple times with different
> sets of
> > > > > "inputs".
> > > > > 
> > > > > 
> > > > > or if I can use loops like For or
> > > > > > While to do the same, keeping a counter in
> order
> > > > > to
> > > > > > make conditions to execute the same
> procedure or
> > > > > same
> > > > > > target with diferent actions.
> > > > > > 
> > > > > >   Is it possible?
> > > > > 
> > > > > When looping, you have to create a
> "kick-out"
> > > > > condition. I used the
> > > > > target's unless attribute. The idea is to
> loop until
> > > > > the property is
> > > > > set. However, because a target can't antcall
> itself,
> > > > > you have to
> > > > > replicate the target and have them
> cross-call each
> > > > > other:
> > > > > 
> > > > > 
> > > > > <target name="worker">
> > > > >   <!-- This does the actual work. May depend
> on
> > > > > other workers. -->
> > > > > </target>
> > > > > 
> > > > > <target name="looper_1" depends="worker"
> > > > > unless="some.condition">
> > > > >   <antcall target="looper_2"/>
> > > > > </target>
> > > > > 
> > > > > <target name="looper_2" depends="worker"
> > > > > unless="some.condition">
> > > > >   <antcall target="looper_1"/>
> > > > > </target>
> > > > > 
> > > > > 
> > > > > This takes care of while loops. I've never
> tried
> > > > > implementing a for
> > > > > loop in Ant. I suppose you could do
> something like
> > > > > the following
> > > > > in the worker target:
> > > > > 
> > > > > <property name="counter" value="counter" />
> > > > > 
> > > > > <target name="worker">
> > > > >   <property name="${counter}."
> value="whatever" />
> > > > > </target>
> > > > > 
> > > > > Then if you wanted to loop 3 times:
> > > > > 
> > > > > <target name="looper_1" depends="worker"
> > > > > unless="counter...">
> > > > >   <antcall target="looper_2"/>
> > > > > </target>
> > > > > 
> > > > > <target name="looper_2" depends="worker"
> > > > > unless="counter...">
> > > > >   <antcall target="looper_1"/>
> > > > > </target>
> > > > > 
> > > > > -- Don
> > > > >
> > > > > >   thank you
> > > > > > VES
> > 
> > =====
> > (holtdl@yahoo.com)
> > 
> > 
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > Make international calls for as low as $.04/minute
> with Yahoo! Messenger
> > http://phonecard.yahoo.com/
> 
=== message truncated ===


=====

_________________________________________________________________

"Puedes sentirte desilusionado si fallas, pero estás condenado si no lo intentas."

"You can get disappointed if you fail down, but you are doomed if you do not try it."

ICQ #  22338121


__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

Mime
View raw message