AvailableTask
  
测试某资源或文件是否存在,并设置某属性为相应的值
 
 
 
例子
 
 
[html] view plain copy
 
   
- <available file="/tmp/test.txt" property="test_txt_exists" value="Yes"/>
 - <available file="/home/foo" type="dir" property="properties.yetanother" />
 - <available file="/home/foo/bar" property="foo.bar" value="Well, yes" />
 
 
 
然后检查/home目录下是否有目录foo,接下来检查/home/foo目录下是否存在名为bar的文件或目录
 
 
如果/tmp/test.txt存在,test_txt_exists属性将被设为Yes,如果/home/foo存在并且为目录,则properties.yetanother被设为true(默认)。
 
 
如果/home/foo/bar存在,foo.bar将被设为“Well,yes”。
 
 
 
 
ChmodTask
 
 
设置文件或目录的权限。
 
 
例子
 
 
[html] view plain copy
 
   
- <chmod file="test.txt" mode="0755" />
 - <chmod file="/home/test" mode="0775" />
 - <chmod file="/home/test/mine.txt" mode="0500" verbose="true" />
 
 
 
支持的嵌套标签
 
 
<fileset>
 
 
 
 
ChownTask
 
 
改变文件或目录的所有者
 
 
例子
 
 
[html] view plain copy
 
   
- <chown file="my-file.txt" user="foo" />
 - <chown file="my-file.txt" user="username.groupname" />
 - <chown file="/home/test/my-directory" user="bar" />
 - <chown file="/home/test/my-file.txt" user="foo" verbose="true" failonerror="false" />
 
 
支持的嵌套标签
  
 
<fileset>
 
  
 
  
ConditionTask
 
  
条件为真时设置某属性值--相当于Available和UpToDate的整合。
 
  
注意
 
  
如果条件为真,属性值默认被设为true;条件为假,属性值不会被设置。你可以通过设置value属性来替代默认值。
 
  
condition是嵌套元素,你必须指定一个条件(且只能为一个)。
 
  
例子
[html] view plain copy
 
    
- <condition property="isMacOrWindows">
 - <or>
 - <os family="mac"/>
 - <os family="windows"/>
 - </or>
 - </condition>
 
 
   
 
  
CopyTask
 
  
拷贝文件或目录
 
  
 
  
注意
 
  
只有当源文件比目标文件新或目标 文件不存在时,文件才会被拷贝。
 
  
可以明确指定进行文件覆盖。
 
  
例子
 
 
一方面,CopyTask直持逐个文件的拷贝:
 
 
[html] view plain copy
 
   
- <copy file="somefile.txt" tofile="/tmp/anotherfile.bak" overwrite="true"/>
 
 
 
[html] view plain copy
 
  
- <copy todir="/tmp/backup" >
 - <fileset dir=".">
 - <include name="**/*.txt" />
 - <include name="**/*.doc" />
 - <include name="**/*.swx" />
 - </fileset>
 - <filelist dir="." files="test.html"/>
 - </copy>
 - <copy todir="build" >
 - <fileset defaultexcludes="false" expandsymboliclinks="true" dir=".">
 - <include name="**/*.php" />
 - </fileset>
 - </copy>
 
 
 
支持的嵌套标签
 
 
<fileset>
 
  
<filelist>
 
  
<filterchain>
 
  
<mapper>
 
 
 
 
DeleteTask
 
 
删除文件或目录
 
 
例子
 
 
[html] view plain copy
 
  
- <-- Delete a specific file -->
 - <delete file="/tmp/foo.bar" />
 - <-- Delete a directory -->
 - <delete dir="/tmp/darl" includeemptydirs="true" verbose="true" failonerror="true" />
 - <-- Delete using a fileset -->
 - <delete>
 - <fileset dir="/tmp">
 - <include name="*.bar" />
 - </fileset>
 - </delete>
 
 
 
支持的嵌套标签
 
 
<fileset>
 
 
 
 
EchoTask
 
 
向标准输出和日志中输出消息
 
 
注意
 
 
可以指定日志级别
 
 
可以直接向文件输出消息,在这种情况下将会默认使用用append选项替代overwrite,日志级别选项将失效。
 
 
除此之外,echotask还可以输出fileset元素中指定的文件的内容。
 
 
[html] view plain copy
 
   
- <echo msg="Phing rocks!" />
 - <echo message="Binarycloud, too." />
 - <echo>And don't forget Propel.</echo>
 - <echo file="test.txt" append="false">This is a test message</echo>
 
 
支持的嵌套标签
  
 
<fileset>
 
 
 
 
ExecTask
 
 
执行shell命令
 
 
注意
 
 
使用这个task,你可以很快为Phing增加一条新的命令。
 
 
如果你经常使用某命令,建议你为它写一个task。
 
 
例子
 
 
[html] view plain copy
 
   
- <-- List the contents of "/home". -->
 - <exec command="ls -l" dir="/home" />
 - <-- Start the make process in "/usr/src/php-4.0". -->
 - <exec command="make" dir="/usr/src/php-4.0" />
 - <-- List the contents of "/tmp" out to a file. -->
 - <exec command="ls -l /tmp > foo.out" escape="false" />
 
 
支持的嵌套标签
  
 
<arg>
 
 
 
 
IfTask
 
 
根据条件的真假执行相应的任务
 
 
属性
 
 
  这个task没有任何属性,待测试的条件通过一组嵌套元素指定。可用的元素参见(
  第五章 Conditons一节)
  
和<condition>一样,只能使用一个条件,你可以使用<and>或<or>将它们连接起来。
 
 
 
你可以使用三种不同的子元素:<elseif>, <then>和<else>。它们是可选项,而非必须的。在一个iftask中<then>和<else>只能出现一次。它们可以包含Phing task。
 
 
例子
 
 
[html] view plain copy
 
  
- <if>
 - <equals arg1="${foo}" arg2="bar" />
 - <then>
 - <echo message="The value of property foo is bar" />
 - </then>
 - <else>
 - <echo message="The value of property foo is not bar" />
 - </else>
 - </if>
 - <if>
 - <equals arg1="${foo}" arg2="bar" />
 - <then>
 - <echo message="The value of property foo is 'bar'" />
 - </then>
 - <elseif>
 - <equals arg1="${foo}" arg2="foo" />
 - <then>
 - <echo message="The value of property foo is 'foo'" />
 - </then>
 - </elseif>
 - <else>
 - <echo message="The value of property foo is not 'foo' or 'bar'" />
 - </else>
 - </if>
 
 
 
MkdirTask
 
 
创建目录,包含任何必要的目录(类似shell的mkdir -p)
 
 
注意
 
 
如果目录存在,则不作任何事情
 
 
例子
 
 
[html] view plain copy
 
   
- <-- Create a temp directory -->
 - <mkdir dir="/tmp/foo" />
 - <-- Using mkdir with a property -->
 - <mkdir dir="${dirs.install}/tmp" />
 
 
  
MoveTask
 
将文件或目录移到新的位置
 
 
注意
 
 
默认情况下,目标文件如果存在,它将被覆盖。如果overwrite被置为false,只能在源文比目标文件新,或者目标文件不存在时,源文件才会被移动。
 
 
如果移动成功,源文件或目录将被删除。
 
 
例子
 
 
[html] view plain copy
 
   
- <-- The following will move the file "somefile.txt" to "/tmp" and
 - change its filename to "anotherfile.bak". It will overwrite
 - an existing file. -->
 - <move file="somefile.txt" tofile="/tmp/anotherfile.bak" overwrite="true"/>
 - <-- This will move the "/tmp" directory to "/home/default/tmp",
 - preserving the directory name. So the final name is
 - "/home/default/tmp/tmp". Empty directories are also copied -->
 - <move file="/tmp" todir="/home/default/tmp" includeemptydirs="true" />
 
 
  
PhingCallTask
  
 
调用同一phing项目中的target
 
 
注意
 
  
<phingcall>可以包含<property>标签,用于定义新的属性。
 
  
只有在<phingcall>之外没有定义时,这些新的属性值才会生效。
 
  
例子
 
 
在下面的例子中,我们定义了property1和foo,它们仅能在被调用的target中访问到。
 
 
[html] view plain copy
 
  
- <target name="foo">
 - <phingcall target="bar">
 - <property name="property1" value="aaaaa" />
 - <property name="foo" value="baz" />
 - </phingcall>
 - </target>
 - <target name="bar" depends="init">
 - <echo message="prop is ${property1} ${foo}" />
 - </target>
 
 
 
 
 
PropertyTask
 
 
用于用户自定义属性值
 
 
例子
 
 
[html] view plain copy
 
   
- <property name="strings.test" value="Harr harr, more power!" />
 - <echo message="${strings.test}" />
 - <property name="foo.bar" value="Yet another property..." />
 - <echo message="${foo.bar}" />
 - <property file="build.properties" />
 
 
 
TouchTask
 
 
TouchTask很像Unix的touch命令:设置文件的modtime。
 
 
注意
 
 
默认修改为当前时间
 
 
例子
 
 
[html] view plain copy
 
   
- <touch file="README.txt" millis="102134111" />
 - <touch file="COPYING.lib" datetime="10/10/1999 09:31 AM" />
 
                










