7
如何在phing中對fileset目標文件中的每個文件執行目標操作?例如:對phing目標中的每個文件執行一個命令
<exec command="cat {$filepath}">
<fileset dir=".">
<include name="*.php">
</fileset>
</exec>
如何在phing中對fileset目標文件中的每個文件執行目標操作?例如:對phing目標中的每個文件執行一個命令
<exec command="cat {$filepath}">
<fileset dir=".">
<include name="*.php">
</fileset>
</exec>
您可以使用文件集的foreach任務,例如:
<?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>
注意,此功能是在2.4.0版本中實現Phing的
<apply executable="cat" parallel="false">
<fileset dir=".">
<include name="*.php">
</fileset>
</apply>
這個是我的phing版本: Phing版本2.3.3 我得到這個錯誤: 初始化嵌套el時出錯ement [wrapped:phing.tasks.system.ForeachTask不支持'fileset'創建者/加法器]] –
2010-06-03 08:18:01
對不起,它不是2.3.1而是2.4.0:http://phing.info/trac/ticket/252最新的穩定版本是2.4.1,你可能要升級。 – nuqqsa 2010-06-03 08:30:52