• 1 رای - 5 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
قالب build.xml برای PhING
#1
یک قالب build.xml تقریباً کامل برای برنامه PhING بهمراه توضیحات:
https://www.phing.info

کد:
<?xml version="1.0" encoding="utf-8"?>

<!-- Conventions/Standards:
   * Filenames consist of no more or less than two elements: name and extension
   * Choose short descriptive filenames (must be less than 31 chars)
   * Names must not contain dots
   * Files containing PHP code must end with the extension .php
   * The name portion of the file must be named exactly like the class it contains
   * Buildfiles and configure rulesets must end with the extension .xml
   * There must be only one class per file (no procedural methods allowed, use a
      separate file for them), with the exception of "inner"-type / helper classes
      that can be declared in the same file as the "outer" / main class

   Source: https://www.phing.info/phing/guide/en/output/hlhtml/#d5e1758
-->

<!-- Project information -->
<project name="TestProject" description="The test project." phingVersion="2" default="main">

<!----- File/Directory ----->

<!-- Sets the mode of file/directory -->
<chmod file="./filename.php" mode="0755"/>
<chmod file="/path/to/somewhere/" mode="0775" quiet="true"/>
<chmod file="./filename.so" mode="0500" verbose="true"/>

<!-- Changes the owner of file/directory -->
<chown file="./filename.php" user="root"/>
<chown file="./filename.dll" user="testname" group="testersgroup"/>
<chown file="./filename.so" user="leader.developersgroup"/>
<chown file="/path/to/somewhere/" user="administrator"/>

<!-- Creates directory -->
<mkdir dir="./directoryname"/>
<mkdir dir="./directoryname" mode="0777"/>
<mkdir dir="${myProperty.install_path}/directoryname"/>

<!-- Deletes file -->
<delete file="/path/to/somewhere/filename.php" verbose="false"/>
<!-- Deletes directory -->
<delete dir="/path/to/somewhere" includeemptydirs="true" failonerror="true"/>

<!-- Copy file/directory -->
<copy file="./filename.php" todir="/path/to/somewhere/filename.bak" overwrite="true"/>
<copy file="./testpath/filename.exe" todir="/path/to/somewhere1/filename.bak" overwrite="false" mode="0755"/>
<copy file="${myProperty.install_path}/directoryname/filename.dll" todir="/path/to/somewhere2/filename.bak" overwrite="false" haltonerror="true"/>
<copy file="./filename.so" todir="/path/to/somewhere3/filename.bak" overwrite="true" verbose="true"/>

<!-- Moves a file or directory to a new file or directory -->
<move file="filename.txt" tofile="/tmp/filename.bak" overwrite="true"/>
<move file="/tmp" todir="/home/default/tmp"/>

<!-- Turns a relative path into an absolute path -->
<property name="relative_path" value="./"/>
<resolvepath propertyName="absolute_path" file="${relative_path}"/>

<!-- Checks if selected partition has the requested space -->
<!--  Linux/Unix -->
<hasfreespace partition="/" needed="125M"/>
<!--  Windows -->
<hasfreespace partition="c:" needed="500M"/>

<!-- Stores size of file into a property -->
<filesize file="./testfile.txt" propertyname="myProperty.testFileSize"/>
<filesize file="${builddir}/${tarball}.tar.${compression}" propertyname="myProperty.finalFileSize"/>

<!-- Gets the directory path of a file then sets a property to it's path -->
<dirname file="filename.php" property="myProperty.filename_path"/>

<!-- Creates a symlink -->
<symlink target="/path/to/original/file" link="/where/to/symlink" overwrite="true"/>

<!-- Loads contents of [text] file into a property -->
<loadfile file="./VERSION.txt" property="version" failonerror="true"/>

<!-- Tests if a directory/file exists then sets a property to a value -->
<available file="./filename.php" type="file" property="is_testphp_exist" value="true"/>
<available file="/path/to/somewhere/" type="dir" property="myProperty.is_that_path_exist" value="1"/>

<!-- Condition -->

<!-- Switch -->
<switch value="${someproperty}">
   <case value="3">
      <echo message="Test message."/>
   </case>

   <case value="testvalue">
      <echo message="Test message."/>
   </case>

   <default>
      <echo message="Test message."/>
   </default>
</switch>

<!-- if/else -->
<if>
      <available file="README.md"/>
   <then>
      <echo message="Don't forget to read README.md file."/>
   </then>
</if>
<if>
      <equals arg1="${someproperty}" arg2="somevalue"/>
   <then>
      <echo message="The value of property someproperty is somevalue"/>
   </then>
   <else>
      <echo message="The value of property someproperty is not somevalue"/>
   </else>
</if>

<!----- PhING / build.xml ----->

<!-- Stores Phing version -->
<phingversion property="myProperty.phingversion"/>
<!-- Stores Phing version if it is 2.9 or higher -->
<phingversion property="phingversion" atleast="2.9"/>

<!-- Force exit build with a message -->
<fail message="Error message!"/>
<!--  Exit build if ${someproperty} is defined -->
<fail if="someproperty" message="Error message!"/>
<!-- Exit build unless ${someproperty} is defined. -->
<fail unless="someproperty" message="Error message!"/>

<!-- Debug/Displays all myProperty in the project -->
<echomyProperty/>
<!-- Debug/Displays all propertyprefix.* in the project -->
<echomyProperty prefix="propertyprefix."/>

<!-- Executes a shell command -->
<exec command="php ./index.php" escape="false" passthru="true"/>
<exec command="notfoundfile" returnProperty="myProperty.fileresult"/>
<exec command="ls -l" dir="~/home"/>

<!-- Calls another build file -->
<phing phingfile="alternative-build-file.xml" inheritAll="true" target="clean"/>

<!-- Defines user property in build file -->
<property name="strings.english.filenotfound" value="File not found!"/>
<property name="myProperty.indexfilename" value="index.php"/>
<property name="myProperty.indexfilename" value="index.php" override="true"/>
<!-- Loads myProperty from system environment with specified value as prefix -->
<property environment="myProperty.PATH"/>

<!-- Echoes a message to the current loggers -->
<echo message="Test message."/>
<echo>Test message #2.</echo>
<!-- Writes a message to file -->
<echo message="Test message #3." file="./filename.php"/>

<!-- Exports all defined myProperty to file -->
<exportmyProperty targetfile="myProperty.output"/>

<!-- Runs a target -->
<runtarget target="clean"/>

<!-- Calculates MD5 or SHA1 hash of file - algorithms: http://php.net/manual/en/function.hash-algos.php -->
<filehash file="./testfile.txt" algorithm="md5" propertyname="myProperty.testFileHash"/>
<filehash file="${builddir}/${tarball}.tar.${compression}" algorithm="sha512" propertyname="myProperty.finalFileHash"/>

<!-- Includes autoload file for execution -->
<autoloader autoloaderpath="./includes/libraries/autoload.php"/>

<!-- Sleeping for short period of time -->
<sleep milliseconds="1"/>
<sleep seconds="5"/>
<sleep minutes="30"/>
<sleep hours="4"/>

<!-- Re-tries task(s) if failed -->
<retry retrycount="3">
<!-- Task -->
</retry>


<!-- Compression/Decompression -->

<!-- Creates tarball archive file -->
<tar destfile="./myfile.tar.gz" basedir="." compression="gzip"/>

<!-- Untar archive(s) -->
<untar file="./myfile.tar.gz" todir="./" forceExtract="true"/>

<!-- Creates zip archive file -->
<zip destfile="./myfile.zip" basedir="." comment="Test comment."/>

<!-- Unzip archive(s) -->
<untar file="./myfile.zip" todir="./" forceExtract="true"/>


<!-- Tools -->

<!-- Runs jsllint tool -->
<jsllint file="path/to/javascript/file.js"/>

<!-- PhING 3: Checks if given file is valid JSON -->
<jsonvalidate file="path/to/json/file.json"/>

<!-- Linux: Wrapper for notify-send, for displaying desktop notifications locally -->
<notifysend title="Message title!" message="message body!"/>

<!-- Runs rsync tool -->
<filesync sourcedir="/path/to/somewhere/" destinationdir="/path/to/somewhere/else/" verbose="true"/>

<!-- Runs ApiGen documentor tool -->
<apigen source="classes" destination="docs" exclude="*/tests/*" title="API Documentation" deprecated="true" todo="false"/>

<!-- Runs Composer dependency manager tool -->
<composer command="install"/>

<!-- Runs xmllint tool -->
<xmllint file="./config.xml" haltonfailure="true"/>

<!-- Runs phpmd tool -->
<phpmd file="path/to/source/file.php" type="text" outfile="./build/reports/pmd.html"/>
<phpmd file="path/to/sources">
   <formatter type="html" outfile="./build/reports/pmd.html"
      allowedFileExtensions="php,php5,php7,phtml,inc"/>
</phpmd>

<!-- Download/Upload file using SCP -->
<scp username="root" password="0123456789" host="webserver" fetch="true"
   todir="/home/backup" file="/www/remote/htdocs/test.html" level="verbose"/>

<!-- executes commands on a remote host using SSh -->
<ssh username="root" password="0123456789" host="webserver" command="ls"
   display="true"/>

<!-- Runs phplint tool -->
<phplint file="path/to/source/file.php" haltonfailure="true"
   tofile="./phplint.html" level="warning" deprecatedAsError="true"/>

<!-- Runs PHP_CodeSniffer tool -->
<phpcodesniffer standard="Generic" format="summary" docGenerator="HTML"
   file="/path/to/source-files/" docFile="/path/to/reports.html"
   showWarnings="true" allowedFileExtensions="php php5 php7 phtml inc"/>

<!-- Git, Svn, HG, FTP, PHPUnit, PHAr etc... -->
</project>

https://gist.github.com/Yousha/da0045864...f523fbf0fa
وبلاگ: Yousha.Blog.ir

صدام: "اگر با ارتش شاه ایران طرف بودیم، یک ماهه جنگ را می بردیم"
http://gulfnews.com/opinion/thinkers/ira...i-1.500997
  پاسخ
تشکر شده توسط : ayoubsys
#2
ممنون دنبال همچین چیزی بودم
  پاسخ
تشکر شده توسط :


پرش به انجمن:


کاربران در حال بازدید این موضوع: 1 مهمان