简体   繁体   中英

phing toString method with fileset

Phing's documentation shows an example that should display a list all php files of a certain folder using a fileset with an id of "sourcefiles":

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

So I put together a build-xml with this task:

<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>

I also tried the one-liner version from the documentation: <fileset id="sourcefiles" dir=".build" includes="**/*.txt"/> .

However, the output is nothing else but exactly that dollar-curly-brace-text as text: '${toString:sourcefiles}' instead of its interpolated result.

phing:toString 方法未插值

What would be the proper way to right it? Is this an error in the docs?
(I am not new to deployment, but new to phing.)

The include element inside your fileset has a non valid pattern. From the documentation

In patterns, one asterisk (*) maps to a part of a file/directory name within a directory level. Two asterisks (**) may include above the "border" of the directory separator.

Your example becomes:

<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>

And will output something like:

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.

Also note that the ${toString:XXX} feature is only available for phing 3.x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM