开发者

Iterating over libraries and execute task in Ant

开发者 https://www.devze.com 2023-02-13 04:41 出处:网络
I need to be able to execute a task for all sub-directories with a certain name in Ant. For each sub-dir, I need to do an exec task

I need to be able to execute a task for all sub-directories with a certain name in Ant. For each sub-dir, I need to do an exec task

How can I do this ? Examples I found use fileset for copy tasks, which I can't use with the exec task, or开发者_运维问答 use a for loop which I can't get to work.

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


You can do this with the Ant apply task. The task iterates over the members of a fileset-like object, and it can process a dirset too.

Here's 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 attibutes as the one-shot exec task.


Did you try something like this (you need the antcontrib for task):

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

This reference taken from here.

0

精彩评论

暂无评论...
验证码 换一张
取 消