Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to iterate (loop) through directories in phing?

Tags:

phing

I want to create phing task for some plugins so the directory structure is something like

root
  - plugin1
    - index.php
  - plugin2
    - index.php

etc..

I want to run same tasks on each subdirectory - for example

  1. generate doc for plugin1
  2. run unit tests for plugin1
  3. deploy plugin1 somewhere
  4. generate doc for plugnin2 ...

Is this possible? I need something like

<foreach param="filename" absparam="absfilename" target="subtask">
  <fileset dir=".">
    <include name="*.php"/>
  </fileset>
</foreach>

but for directories.

Or do I have to write build.xml for each plugin standalone?

Thanks a lot.

like image 859
Zap Avatar asked Dec 13 '22 17:12

Zap


1 Answers

Finally I discovered selectors which can solve my request:

<foreach param="dirname" absparam="absname" target="subtask">
  <fileset dir="${ws}/source/">
        <type type="dir" />
        <depth max="0" min="0" />
  </fileset>
</foreach>

and call some task to do stuff

<target name="subtask">
    <echo msg="${dirname} ${absname}" />
</target>
like image 137
Zap Avatar answered Jan 05 '23 14:01

Zap