Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

exec a command on each file in a phing target

Tags:

php

phing

How can I execute a target action in phing on each file of a fileset target? For example:

<exec command="cat {$filepath}">
  <fileset dir=".">
    <include name="*.php">
  </fileset>
</exec>
like image 228
Arsenio Siani Avatar asked May 13 '10 14:05

Arsenio Siani


Video Answer


1 Answers

You can use the foreach task with filesets, e.g.:

<?xml version="1.0" encoding="utf-8"?>
<project name="cat-fileset" basedir="." default="iterate">
    <target name="iterate">
        <foreach param="fname" absparam="abs-fname" target="cat">
            <fileset dir="${project.basedir}">
                <include name="*.php" />
            </fileset>
        </foreach>
    </target>    
    <target name="cat">
        <exec command="cat ${abs-fname}" 
            escape="false"
            checkreturn="true"
            passthru="true" />
    </target>
</project>

Note that this feature was implemented in version 2.4.0 of Phing

like image 108
nuqqsa Avatar answered Oct 07 '22 00:10

nuqqsa