How can I use something like an array or list in Ant?

I have a list of strings (for example, "piyush, kumar") in an Ant script for which I want to assign piyush to var1, for example <var name="var1" value="piyush"/> and kumar , for var2, like <var name="var2" value="kumar"/> .

So far, I am using the build file, for example:

 <?xml version="1.0"?> <project name="cutter" default="cutter"> <target name="cutter"> <for list="piyush,kumar" param="letter"> <sequential> <echo>var1 @{letter}</echo> </sequential> </for> </target> </project> 

I'm not sure how to do this - any suggestions?

+6
source share
1 answer

Here is an example using ant -contrib variable and math

 <var name="index" value="1"/> <for list="piyush,kumar" param="letter"> <sequential> <property name="var${index}" value="@{letter}" /> <math result="index" operand1="${index}" operation="+" operand2="1" datatype="int" /> </sequential> </for> <echoproperties prefix="var" /> 

Conclusion:

 [echoproperties] var1=piyush [echoproperties] var2=kumar 

This is all really disliked by w41>, as if you established what you were going to do with them?

Instead, you can use the Ant script task for this non-declarative processing.

+8
source

Source: https://habr.com/ru/post/896641/


All Articles