【问题标题】:how to iterate (loop) through directories in phing?如何遍历 phing 中的目录?
【发布时间】:2010-12-15 14:54:03
【问题描述】:

我想为一些插件创建 phing 任务,所以目录结构类似于

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

等等。

我想在每个子目录上运行相同的任务 - 例如

  1. 为 plugin1 生成文档
  2. 为插件 1 运行单元测试
  3. 在某处部署 plugin1
  4. 为plugnin2 生成文档 ...

这可能吗?我需要类似的东西

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

但对于目录。

或者我必须为每个插件单独编写 build.xml 吗?

非常感谢。

【问题讨论】:

    标签: phing


    【解决方案1】:

    最后我发现了可以解决我的请求的选择器:

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

    并调用一些任务来做事

    <target name="subtask">
        <echo msg="${dirname} ${absname}" />
    </target>
    

    【讨论】:

      猜你喜欢
      • 2011-07-23
      • 1970-01-01
      • 1970-01-01
      • 2010-11-27
      • 2011-06-22
      • 2011-01-07
      • 1970-01-01
      • 2023-03-31
      • 2016-01-22
      相关资源
      最近更新 更多