How can I use Ant foreach iteration with values ​​from a file?

In our Ant build environment, I have to perform the same task for several elements. The AntContrib foreach task is useful for this. However, the list is in the parameter where I have the list in the file. How can I iterate over elements in a file as foreach-like in Ant? Something like (pseudo-code):

<foreach target="compile-module" listFromFile="$fileWithModules"/> 

I am happy to write a custom task and welcome any suggestion on possible solutions.

+4
source share
1 answer

I tried to load the file into the property and iterate over it, it worked fine for me:

 <loadfile property="file-content" srcFile="${fileWithModules}"/> <foreach target="compile-module" list="${file-content}" delimiter="${line.separator}" param="your-param-used-in-target"/> 
+10
source

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


All Articles