Iterating Libraries and Performing a Task in Ant

I need to complete a task for all subdirectories with a specific name in Ant. For each sub-dir I need to execute the exec task

How can i do this? In the examples, I found a set of files for copy tasks, which I cannot use with the exec task, or use a for loop, which I cannot get to work.

I also tried Javascript, but I can't get FSO to work at all.

+4
source share
2 answers

You can do this with the Ant apply task. The task iterates over objects like file sets, and it can handle the dirset .

Here is an example:

 <!-- all directories directly under working dir --> <dirset id="my.dirs" dir="." includes="*" /> <apply executable="ls"> <arg value="-l" /> <dirset refid="my.dirs" /> </apply> 

Apply has similar settings as a single-shot exec task.

+3
source

You tried something like this (you need antcontrib for the task ):

 <for param="file"> <path> <fileset dir="${yourdirectory}"/> </path> <sequential> <!-- do the work you need to here --> <echo>Filename === @{file} </sequential> </for> 

This link is taken from here .

+1
source

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


All Articles