phing toString 方法与文件集

phing toString method with fileset

提问人:Robert Wildling 提问时间:11/29/2020 最后编辑:Robert Wildling 更新时间:12/1/2020 访问量:62

问:

Phing 的文档显示了一个示例,该示例应使用标识为“sourcefiles”的文件集显示某个文件夹的所有 php 文件列表:

https://www.phing.info/guide/chunkhtml/ch04s02.html(见 4.2.4)

因此,我将此任务放在一起构建xml:

<project default="countFile">
    <property name="BUILD_DIR" value="./buildTest"/>
    <target name="dist" depends="build">
        <fileset id="sourcefiles" dir="${BUILD_DIR}">
            <include name="./*.*" />
        </fileset>
        <echo>files in build dir: ${toString:sourcefiles}</echo>
        <echo>build dir: ${BUILD_DIR}</echo>
        <echo>OS: ${os.name}</echo>
    </target>
</project>

我还尝试了文档中的单行版本:.<fileset id="sourcefiles" dir=".build" includes="**/*.txt"/>

但是,输出只是将美元大括号文本作为文本:“${toString:sourcefiles}”而不是其插值结果。

phing: toString method not interpolated

纠正它的正确方法是什么?这是文档中的错误吗?
(我不是部署新手,而是 phing 的新手。

phing的

评论


答:

1赞 Siad Ardroumli 12/1/2020 #1

文件集中的元素具有无效模式。从文档include

在模式中,一个星号 (*) 映射到 目录级别。目录的“边框”上方可以包含两个星号 (**) 分隔符。

您的示例变为:

<project default="countFile">
    <property name="BUILD_DIR" value="./buildTest"/>
    <target name="dist" depends="build">
        <fileset id="sourcefiles" dir="${BUILD_DIR}">
            <include name="*.*" />
        </fileset>
        <echo>files in build dir: ${toString:sourcefiles}</echo>
        <echo>build dir: ${BUILD_DIR}</echo>
        <echo>OS: ${os.name}</echo>
    </target>
</project>

并将输出如下内容:

Buildfile: C:\Users\XXX\test\build.xml
[autoloader] Loading autoloader from C:\Users\XXX\test/bootstrap.php
      [php] Evaluating PHP expression: ini_set('error_reporting', -1);
      [php] Evaluating PHP expression: ini_set('memory_limit', -1);
      [php] Evaluating PHP expression: ini_set('date.timezone', 'UTC');

Phing Build Tests > test:

     [echo] files in build dir: bootstrap.php;build.xml;phpunit-sparse.xml;phpunit.xml

BUILD FINISHED

Total time: 0.4785 seconds



Build finished at 30.11.2020 23:19 with exit code 0.

另请注意,该功能仅适用于 phing 3.x${toString:XXX}

评论

0赞 Robert Wildling 12/1/2020
我错过了该指南适用于第 3 版!谢谢你向我指出这一点!