What is it you are trying to achieve? I have used a comma-separated string property, split it and iterated over it (using ant-contrib). Would that work for you rather than writing a custom task?

hth,
Vijay

markww wrote:
Hmm I just read through a custom Task tutorial, but I don't think they'll
help, because you can't specify a variable number of attributes, they must
be known in advance. In the examples I've read, your custom Task class has
to have getters and setters for all the attributes you want to use. But if I
want to let my user specify an arbitrary number of attributes, I don't think
that's possible... please correct me if I'm wrong!

Thanks


mgainty wrote:
Hey Mark-

no declaration of property array as far as I can see you can feel free to
create your own as in this example

public class MyTask extends Task {
     private List conditions = new ArrayList();
     public void add(Condition c) {
         conditions.add(c);
     }
     public void execute() {
      // iterator over the conditions
     }
}


     One may define and use this class like this:


     <taskdef name="mytask" classname="MyTask" classpath="classes"/>
<typedef name="condition.equals"
          classname="org.apache.tools.ant.taskdefs.conditions.Equals"/>
<mytask>
     <condition.equals arg1="${debug}" arg2="true"/>
</mytask>

   There are a number of hidden implementation details such as which
constructors are created and used but the
mechanics of creating the stub are here..more info available at
http://ant.apache.org/manual/develop.html

Maybe some of the committers can weigh in???
Martin

______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official
business of Sender. This transmission is of a confidential nature and
Sender does not endorse distribution to any party other than intended
recipient. Sender does not necessarily endorse content contained within
this transmission.


Date: Thu, 14 Aug 2008 13:14:33 -0700
From: [EMAIL PROTECTED]
To: [email protected]
Subject: Property array?


Hi,

Is there any way to make an array property in Ant? I want to write some
stuff to a file based on an array property. Something like the user
enters
this:

    <property array name = "colors">
        <val = "red">
        <val = "green">
        <val = "blue">
     </property array>

     for (i = 0; i<  ${colors}; i++) {
         <echo file="myfile.txt" append="yes" message="${colors[i]}" />
     }

Yeah I'm just making the syntax up as I go along - anything like that?

Thanks
--
View this message in context:
http://www.nabble.com/Property-array--tp18988851p18988851.html
Sent from the Ant - Users mailing list archive at Nabble.com.


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

_________________________________________________________________
Reveal your inner athlete and share it with friends on Windows Live.
http://revealyourinnerathlete.windowslive.com?locale=en-us&ocid=TXT_TAGLM_WLYIA_whichathlete_us


Reply via email to