Re: Ant and Jelly properties

2003-03-17 Thread Theunis de Jongh
Pete Kazmier wrote:

 goal name=init

   !-- Create a property object --
   j:new var=component1 className=java.util.Properties/
   j:set var=dummy value=${component1.setProperty('dir', 'directory1')}/
   j:set var=dummy value=${component1.setProperty('name', 'name1')}/
   !-- Create another property object --
   j:new var=component2 className=java.util.Properties/
   j:set var=dummy value=${component2.setProperty('dir', 'directory2')}/
   j:set var=dummy value=${component2.setProperty('name', 'name2')}/

   !-- Save the property objects into a list --
   j:new var=components className=java.util.ArrayList/
   j:set var=dummy value=${components.add(component1)}/
   j:set var=dummy value=${components.add(component2)}/

 /goal

 goal name=process prereqs=init

   !-- Iterator over the list we created in the 'init' goal --
   j:forEach var=component items=${components}
 echo
   component.dir = ${component.dir}
   component.name = ${component.name}
 /echo
   /j:forEach
 /goal
Hope that helps.

-Pete
 

Thanks, Pete.

This helps a tremendous lot. It will work beautifully.

Kind regards,

--

Theunis de Jongh	
EPI-USE Systems (Pty) Ltd.   We make you shine!
http://www.epiuse.com
mailto:[EMAIL PROTECTED]
switchboard : (012) 368-8400  
direct line : (012) 368-8481
fax : (012) 348-2709
cell: (082) 653 1535

This message may contain information that is proprietary or confidential
and is intended only for the addressee named above.  If you are not the
addressee or authorized to receive this message for the addressee, you
may not use, copy or disclose to anyone this message or its contents.
If you have received this message in error, please notify me immediately
and permanently destroy any copies you may have.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Ant and Jelly properties

2003-03-13 Thread Pete Kazmier
 On Mon, 10 Mar 2003 16:36:19 +0200, Theunis de Jongh said:

Theunis Let's say I have 2 jelly properties : component1.dir and
Theunis component2.dir.

Theunis Now I also have the following jelly property :
Theunis  j:set var=components value=component1,
Theunis  component2 /

Theunis These properties are defined in an init goal, which is
Theunis prerequisite to several subgoals:. The aim is to have
Theunis several types of properties for each type of component
Theunis e.g. component1.name, component1.propertyfile etc.

Theunis In a subgoal, the components property is tokenized using
Theunis jelly, yielding component1 and component2 as tokens.

Theunis The intention is to use it as follows :

Theunis j:set var=dirname value=${token}.dir} /

Theunis The value for dirname is thus component1.dir and
Theunis component2.dir on successive iterations.

Not quite sure if I understand what your problem is, but once you put
something in the Jelly context, you have access to it in your other
goals.  So, taking the example you presented above, you could just do
something like this (no need to tokenize, just use a real list):

  goal name=init

!-- Create a property object --
j:new var=component1 className=java.util.Properties/
j:set var=dummy value=${component1.setProperty('dir', 'directory1')}/
j:set var=dummy value=${component1.setProperty('name', 'name1')}/

!-- Create another property object --
j:new var=component2 className=java.util.Properties/
j:set var=dummy value=${component2.setProperty('dir', 'directory2')}/
j:set var=dummy value=${component2.setProperty('name', 'name2')}/

!-- Save the property objects into a list --
j:new var=components className=java.util.ArrayList/
j:set var=dummy value=${components.add(component1)}/
j:set var=dummy value=${components.add(component2)}/

  /goal

  goal name=process prereqs=init

!-- Iterator over the list we created in the 'init' goal --
j:forEach var=component items=${components}
  echo
component.dir = ${component.dir}
component.name = ${component.name}
  /echo
/j:forEach
  /goal


Hope that helps.

-Pete

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]