Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yangboz/4231728 to your computer and use it in GitHub Desktop.
Save yangboz/4231728 to your computer and use it in GitHub Desktop.
Ant xml for PHP project with CI feature,include phpcs,test, phpmd, phpcpd, pdepend,phpdoc,phpcb,phploc,lint
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<!--
@see:http://agile.dzone.com/news/continuous-integration-php
-->
<project name="XXX/Jenkins" default="build" basedir=".">
<!-- $Id: build.xml 102 2012-01-19 14:39:10Z abtris $ -->
<property name="output" location="${basedir}/build/"/>
<property name="src" location="${basedir}/application/"/>
<property name="basedir" value="."/>
<!-- Clean dirs -->
<target name="clean">
<delete>
<fileset dir="${output}" includes="**/*"/>
</delete>
</target>
<!-- Create dirs -->
<target name="init">
<mkdir dir="${output}/phpcs/"/>
<mkdir dir="${output}/phpmd/"/>
<mkdir dir="${output}/cpd/"/>
<mkdir dir="${output}/pdepend/"/>
<mkdir dir="${output}/api/"/>
</target>
<!-- Main Target -->
<target name="build" depends="clean, init, phpcs,test, phpmd, phpcpd, pdepend,phpdoc,phpcb,phploc,lint"/>
<!-- PHPUnit -->
<target name="test">
<exec executable="phpunit" failonerror="false" dir="${basedir}/tests">
<arg line=" --log-junit=${output}/logs/phpunit.xml --coverage-clover ${output}/coverage/clover.xml --coverage-html ${output}/coverage/ ${basedir}/tests/ApbSAAStestsSuite.php "/>
</exec>
</target>
<!-- PHP CodeSniffer -->
<target name="phpcs">
<exec executable="phpcs">
<arg line=" --report=checkstyle --report-file=${output}/phpcs/checkstyle.xml --standard=Zend ${src}/controllers/ "/>
</exec>
</target>
<!-- PHP Mess Detector -->
<target name="phpmd">
<exec executable="phpmd">
<arg line=" ${src}/controllers/ xml codesize,unusedcode,naming,design --reportfile ${output}/phpmd/messdetector.xml --exclude ${basedir}/tests/ "/>
</exec>
</target>
<!-- PHP Copy/Paste Detector -->
<target name="phpcpd">
<exec executable="phpcpd">
<arg line="--log-pmd ${output}/cpd/phpcpd.xml ${src}/controllers/"/>
</exec>
</target>
<!-- PHP Depend -->
<target name="pdepend">
<exec executable="pdepend" description="Calculate software metrics using PHP_Depend">
<arg line=" --jdepend-xml=${output}/pdepend/jdepend.xml --jdepend-chart=${output}/pdepend/dependencies.svg --overview-pyramid=${output}/pdepend/overview-pyramid.svg --ignore=tests/ ${basedir} "/>
</exec>
</target>
<!-- PHP Documetor -->
<target name="phpdoc" description="Generate API documentation using PHPDocumentor">
<exec executable="phpdoc">
<arg line=" -d ${basedir}/application/controllers/API -t ${basedir}/build/api -ti AutoPhotobook PHP5 REST API -dn API -ric ${basedir}/ "/>
</exec>
</target>
<!-- PHP Code Browser -->
<target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser">
<exec executable="phpcb">
<arg value="--log"/>
<arg path="${basedir}/build/logs"/>
<arg value="--source"/>
<arg path="${src}"/>
<arg value="--output"/>
<arg path="${basedir}/build/code-browser"/>
</exec>
</target>
<!-- PHP LOC(measure the project size) -->
<target name="phploc" description="Measure project size using PHPLOC">
<exec executable="phploc">
<arg value="--log-csv"/>
<arg value="${basedir}/build/logs/phploc.csv"/>
<arg path="${basedir}/src"/>
</exec>
</target>
<!--
PHP LINT(can be used to perform a syntax check of the project sources)
-->
<target name="lint">
<apply executable="php" failonerror="true">
<arg value="-l"/>
<fileset dir="${src}/controllers/">
<include name="**/*.php"/>
<!-- <exclude name="third_party/**/*.php"/> -->
<modified/>
</fileset>
<fileset dir="${src}/models/">
<include name="**/*.php"/>
<modified/>
</fileset>
<!-- <fileset dir="${src}/views/"> -->
<!-- <include name="**/*.php"/> -->
<!-- <modified/> -->
<!-- </fileset> -->
</apply>
</target>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment