Created
March 12, 2014 11:33
-
-
Save ovr/9505140 to your computer and use it in GitHub Desktop.
Perfect Ant Build Script For PHP project in CI use
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project name="Uniqhand" default="build" basedir="."> | |
<property name="source" value="${basedir}/.."/> | |
<property name="appsource" value="${source}/application"/> | |
<property name="libsource" value="${source}/library"/> | |
<target name="clean" | |
description="Clean up artifact directories"> | |
<delete dir="${basedir}/build"/> | |
</target> | |
<target name="prepare" description="Create artifact directories"> | |
<mkdir dir="${basedir}/build"/> | |
<mkdir dir="${basedir}/build/logs"/> | |
<mkdir dir="${basedir}/build/phpdoc"/> | |
<mkdir dir="${basedir}/build/docblox"/> | |
<mkdir dir="${basedir}/build/code-browser"/> | |
<mkdir dir="${basedir}/build/coverage"/> | |
<mkdir dir="${basedir}/build/pdepend"/> | |
<mkdir dir="${basedir}/build/phpdcd"/> | |
</target> | |
<target name="phpunit" description="Run unit tests using PHPUnit and generates reports"> | |
<exec dir="${basedir}" executable="phpunit" failonerror="true"> | |
<arg line="--configuration phpunit_with_coverage.xml" /> | |
</exec> | |
</target> | |
<target name="parallelTasks" | |
description="Run the pdepend, phpmd, phpcpd, phpdcd, phpcs, phpdoc / docblox and phploc tasks in parallel using a maximum of 2 threads."> | |
<parallel threadCount="2"> | |
<sequential> | |
<antcall target="pdepend"/> | |
<antcall target="phpmd"/> | |
</sequential> | |
<antcall target="phpcpd"/> | |
<antcall target="phpdcd"/> | |
<antcall target="phpcs"/> | |
<antcall target="phpdoc"/> | |
<antcall target="docblox"/> | |
<antcall target="phploc"/> | |
</parallel> | |
</target> | |
<target name="pdepend" | |
description="Generate jdepend.xml and software metrics charts using PHP_Depend"> | |
<exec executable="pdepend"> | |
<arg line="--jdepend-xml=${basedir}/build/logs/jdepend.xml | |
--jdepend-chart=${basedir}/build/pdepend/dependencies.svg | |
--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg | |
--suffix=php | |
--ignore=tests,Zend,Doctrine,ZFDoctrine,PHPExcel,scripts | |
${source}" /> | |
</exec> | |
</target> | |
<target name="phpmd" | |
description="Generate pmd.xml using PHPMD"> | |
<exec executable="phpmd" failonerror="false"> | |
<arg line="${source} xml codesize,unusedcode | |
--reportfile ${basedir}/build/logs/pmd.xml | |
--exclude tests,Zend,Doctrine,ZFDoctrine,PHPExcel,scripts | |
--suffixes php" /> | |
</exec> | |
</target> | |
<target name="phpcpd" description="Generate pmd-cpd.xml using PHPCPD"> | |
<exec executable="phpcpd" failonerror="false"> | |
<arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml | |
--exclude ${libsource}/Zend | |
--exclude ${libsource}/Doctrine | |
--exclude ${libsource}/ZFDoctrine | |
--exclude ${libsource}/PHPExcel | |
${appsource} ${libsource}" /> | |
</exec> | |
</target> | |
<target name="phpdcd" description="Generate pmd-dcd.xml using PHPCPD"> | |
<exec executable="phpdcd" output="${basedir}/build/logs/pmd-dcd.txt" failonerror="false"> | |
<arg line="${appsource} | |
--exclude tests,Zend,Doctrine,ZFDoctrine,PHPExcel | |
--suffixes php" /> | |
</exec> | |
</target> | |
<target name="phploc" | |
description="Generate phploc.xml"> | |
<exec dir="${basedir}" executable="phploc" failonerror="false"> | |
<arg line="--log-xml ${basedir}/build/logs/phploc.xml | |
--log-csv ${basedir}/build/logs/phploc.csv | |
--exclude ${libsource}/Zend | |
--exclude ${libsource}/Doctrine | |
--exclude ${libsource}/ZFDoctrine | |
--exclude ${libsource}/PHPExcel | |
${appsource} ${libsource}" /> | |
</exec> | |
</target> | |
<target name="phpcs" | |
description="Generate checkstyle.xml using PHP_CodeSniffer"> | |
<exec executable="phpcs" output="/dev/null" dir="${source}/"> | |
<arg line="--report=checkstyle | |
--report-file=${basedir}/build/logs/checkstyle.xml | |
--standard=Sebastian | |
--ignore=*/Zend/*,*/Doctrine/*, */ZFDoctrine/*, */PHPExcel/* | |
${appsource} ${libsource}" /> | |
</exec> | |
</target> | |
<target name="phpdoc" | |
description="Generate API documentation using phpDocumentor"> | |
<exec executable="phpdoc" failonerror="false"> | |
<arg line="--directory ${appsource},${libsource}/Custom | |
--ignore tests | |
--target ${basedir}/build/phpdoc" /> | |
</exec> | |
</target> | |
<target name="docblox" | |
description="Generate API documentation using DocBlox"> | |
<exec executable="docblox" failonerror="false"> | |
<arg line="--directory ${appsource},${libsource}/Uniqhand | |
--ignore tests | |
--target ${basedir}/build/docblox | |
--title '${ant.project.name}'" /> | |
</exec> | |
</target> | |
<target name="phpcb" | |
description="Aggregate tool output with PHP_CodeBrowser"> | |
<exec executable="phpcb"> | |
<arg line="--log ${basedir}/build/logs | |
--source ${appsource} | |
--output ${basedir}/build/code-browser" /> | |
</exec> | |
</target> | |
<target name="build" depends="clean,prepare,parallelTasks,phpunit,phpcb"/> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment