ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vijay Aravamudhan <avij...@gmail.com>
Subject Re: Property array?
Date Fri, 15 Aug 2008 02:05:46 GMT
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: markww@gmail.com
>>> To: user@ant.apache.org
>>> 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: user-unsubscribe@ant.apache.org
>>> For additional commands, e-mail: user-help@ant.apache.org
>>>
>>>        
>> _________________________________________________________________
>> 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
>>
>>      
>
>    

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message