首页 > 其他分享 >【转】phing用户手册之core task译文

【转】phing用户手册之core task译文

时间:2022-11-11 23:01:49浏览次数:67  
标签:core task 文件 plain html 用户手册 copy 目录 view


AvailableTask
测试某资源或文件是否存在,并设置某属性为相应的值



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <available file="/tmp/test.txt" property="test_txt_exists" value="Yes"/>  
  2. <available file="/home/foo" type="dir" property="properties.yetanother" />  
  3. <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​​

 



  1. <chmod file="test.txt" mode="0755" />  
  2. <chmod file="/home/test" mode="0775" />  
  3. <chmod file="/home/test/mine.txt" mode="0500" verbose="true" />  



支持的嵌套标签



<fileset>



 



ChownTask



改变文件或目录的所有者



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <chown file="my-file.txt" user="foo" />  
  2. <chown file="my-file.txt" user="username.groupname" />  
  3. <chown file="/home/test/my-directory" user="bar" />  
  4. <chown file="/home/test/my-file.txt" user="foo" verbose="true" failonerror="false" />  


支持的嵌套标签



<fileset>



 



ConditionTask



条件为真时设置某属性值--相当于Available和UpToDate的整合。



注意



如果条件为真,属性值默认被设为true;条件为假,属性值不会被设置。你可以通过设置value属性来替代默认值。



condition是嵌套元素,你必须指定一个条件(且只能为一个)。



例子

[html]  ​​view plain​​ ​​copy​​

 



  1. <condition property="isMacOrWindows">  
  2. <or>  
  3. <os family="mac"/>  
  4. <os family="windows"/>  
  5. </or>  
  6. </condition>  






CopyTask



拷贝文件或目录



 



注意



只有当源文件比目标文件新或目标 文件不存在时,文件才会被拷贝。



可以明确指定进行文件覆盖。



例子



一方面,CopyTask直持逐个文件的拷贝:



[html]  ​​view plain​​ ​​copy​​

 



  1. <copy file="somefile.txt" tofile="/tmp/anotherfile.bak" overwrite="true"/>  



[html]  ​​view plain​​ ​​copy​​

 



  1. <copy todir="/tmp/backup" >  
  2. <fileset dir=".">  
  3. <include name="**/*.txt" />  
  4. <include name="**/*.doc" />  
  5. <include name="**/*.swx" />  
  6. </fileset>  
  7. <filelist dir="." files="test.html"/>  
  8. </copy>  
  9.   
  10. <copy todir="build" >  
  11. <fileset defaultexcludes="false" expandsymboliclinks="true" dir=".">  
  12. <include name="**/*.php" />  
  13. </fileset>  
  14. </copy>  



支持的嵌套标签



<fileset>



<filelist>



<filterchain>



<mapper>



 



DeleteTask



删除文件或目录



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <-- Delete a specific file -->  
  2. <delete file="/tmp/foo.bar" />  
  3. <-- Delete a directory -->  
  4. <delete dir="/tmp/darl" includeemptydirs="true" verbose="true" failonerror="true" />  
  5. <-- Delete using a fileset -->  
  6. <delete>  
  7. <fileset dir="/tmp">  
  8. <include name="*.bar" />  
  9. </fileset>  
  10. </delete>  



支持的嵌套标签



<fileset>



 



EchoTask



向标准输出和日志中输出消息



注意



可以指定日志级别



可以直接向文件输出消息,在这种情况下将会默认使用用append选项替代overwrite,日志级别选项将失效。



除此之外,echotask还可以输出fileset元素中指定的文件的内容。



[html]  ​​view plain​​ ​​copy​​

 



  1. <echo msg="Phing rocks!" />  
  2. <echo message="Binarycloud, too." />  
  3. <echo>And don't forget Propel.</echo>  
  4. <echo file="test.txt" append="false">This is a test message</echo>  


支持的嵌套标签



<fileset>



 



ExecTask



执行shell命令



注意



使用这个task,你可以很快为Phing增加一条新的命令。



如果你经常使用某命令,建议你为它写一个task。



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <-- List the contents of "/home". -->  
  2. <exec command="ls -l" dir="/home" />  
  3. <-- Start the make process in "/usr/src/php-4.0". -->  
  4. <exec command="make" dir="/usr/src/php-4.0" />  
  5. <-- List the contents of "/tmp" out to a file. -->  
  6. <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​​

 



  1. <if>  
  2. <equals arg1="${foo}" arg2="bar" />  
  3. <then>  
  4. <echo message="The value of property foo is bar" />  
  5. </then>  
  6. <else>  
  7. <echo message="The value of property foo is not bar" />  
  8. </else>  
  9. </if>  
  10. <if>  
  11. <equals arg1="${foo}" arg2="bar" />  
  12. <then>  
  13. <echo message="The value of property foo is 'bar'" />  
  14. </then>  
  15. <elseif>  
  16. <equals arg1="${foo}" arg2="foo" />  
  17. <then>  
  18. <echo message="The value of property foo is 'foo'" />  
  19. </then>  
  20. </elseif>  
  21. <else>  
  22. <echo message="The value of property foo is not 'foo' or 'bar'" />  
  23. </else>  
  24. </if>  



MkdirTask



创建目录,包含任何必要的目录(类似shell的mkdir -p)



注意



如果目录存在,则不作任何事情



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <-- Create a temp directory -->  
  2. <mkdir dir="/tmp/foo" />  
  3.   
  4. <-- Using mkdir with a property -->  
  5. <mkdir dir="${dirs.install}/tmp" />  



MoveTask


将文件或目录移到新的位置



注意



默认情况下,目标文件如果存在,它将被覆盖。如果overwrite被置为false,只能在源文比目标文件新,或者目标文件不存在时,源文件才会被移动。



如果移动成功,源文件或目录将被删除。



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <-- The following will move the file "somefile.txt" to "/tmp" and  
  2. change its filename to "anotherfile.bak". It will overwrite  
  3. an existing file. -->  
  4.   
  5. <move file="somefile.txt" tofile="/tmp/anotherfile.bak" overwrite="true"/>  
  6.   
  7. <-- This will move the "/tmp" directory to "/home/default/tmp",  
  8. preserving the directory name. So the final name is  
  9. "/home/default/tmp/tmp". Empty directories are also copied -->  
  10. <move file="/tmp" todir="/home/default/tmp" includeemptydirs="true" />  



PhingCallTask



调用同一phing项目中的target



注意



<phingcall>可以包含<property>标签,用于定义新的属性。



只有在<phingcall>之外没有定义时,这些新的属性值才会生效。



例子



在下面的例子中,我们定义了property1和foo,它们仅能在被调用的target中访问到。



[html]  ​​view plain​​ ​​copy​​

 



  1. <target name="foo">  
  2. <phingcall target="bar">  
  3. <property name="property1" value="aaaaa" />  
  4. <property name="foo" value="baz" />  
  5. </phingcall>  
  6.   
  7. </target>  
  8. <target name="bar" depends="init">  
  9. <echo message="prop is ${property1} ${foo}" />  
  10. </target>  



 



PropertyTask



用于用户自定义属性值



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <property name="strings.test" value="Harr harr, more power!" />  
  2. <echo message="${strings.test}" />  
  3. <property name="foo.bar" value="Yet another property..." />  
  4. <echo message="${foo.bar}" />  
  5. <property file="build.properties" />  



TouchTask



TouchTask很像Unix的touch命令:设置文件的modtime。



注意



默认修改为当前时间



例子



[html]  ​​view plain​​ ​​copy​​

 



  1. <touch file="README.txt" millis="102134111" />  
  2. <touch file="COPYING.lib" datetime="10/10/1999 09:31 AM" />  


标签:core,task,文件,plain,html,用户手册,copy,目录,view
From: https://blog.51cto.com/u_15107509/5845539

相关文章

  • 篇(3)-Asp.Net Core入门实战-数据库配置说明
    入门实战-创建数据库和安装NuGet软件包注意,我们用到asp.netcore新功能中的所谓CodeFirst或者DbFirst,我们先不管这功能,为了快速上手简单功能,我计划使用EF(微软新的数据......
  • 【sed 用户手册翻译】: 3 sed scrpts
    这是对sed用户手册的翻译,有翻译不正确的地方请指出https://www.gnu.org/software/sed/manual/sed.html第三章sed脚本3.1sed脚本介绍3.2sed命令摘要3.3命令s......
  • ASP.Net Core Web 在IIS下的发布流程
    1.新建项目,选择Asp.NETWeb应用程序2.选择Web应用程序(模型视图控制器)3.鼠标右键项目,选择【发布】4.选择【IIS、FTP等】5.发布方法选择【文件......
  • .netCore JWT配置 token验证
    1.安装Microsoft.AspNetCore.Authentication.JwtBearer2.在appsetting.json中,添加一个Jwt节点"Jwt":{"SecretKey":"[email protected]","Issuer":"......
  • 【HMS Core】华为分析服务通过REST方式上报用户行为,控制台为何无法查询到相关数据?
    1、问题描述项目中集成了华为分析SDK,并且使用了REST方式调用上报用户行为的接口。遇到的问题是:上报完成之后,在控制台的实时概览中无法查询到该接口上报的相关数据,但是接口确......
  • Multi-task Learning 理论(多任务学习)
    一.多任务学习理论1.1多任务学习的定义如果有\(n\)个任务(传统的深度学习方法旨在使用一种特定模型仅解决一项任务),而这\(n\)个任务或它们的一个子集彼此相关但不完全相......
  • android属性之clearTaskOnLaunch
    clearTaskOnLaunch有没有这样的需求,每次从桌面进入都启动根Activity?可以使用这个属性实现哦,下面通过一个实例来看一下效果:1.MainActivity.java(根Activity):packagecom.examp......
  • FLAG_ACTIVITY_NEW_TASK 和 taskAffinity
    这俩货在一起可以控制Intent时是否新启动一个任务栈,下面通过实例看一下,这俩货怎么配合才能真正新启动一个任务栈额。一、只设置taskAffinity:MainActivity.java:packagecom.......
  • Android中Task任务栈的分配
    首先我们来看下Task的定义,Google是这样定义Task的:ataskiswhattheuserexperiencesasan"application."It'sagroupofrelatedactivities,arrangedinastack.......
  • Android--taskAffinity属性
    Activity的归属,也就是Activity应该在哪个Task中,Activity与Task的吸附关系。我们知道,一般情况下在同一个应用中,启动的Activity都在同一个Task中,它们在该Task中度过自己的生命......