<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project>
<project name="phpGenerics" default="build">
<!-- Uncomment the following when the tools are in ${basedir}/vendor/bin -->
<property name="toolsdir" value="${basedir}/vendor/bin/" />
<property name="phpbin" value="php" />
<!-- ========================================================================================================= -->
<macrodef name="call-php">
<attribute name="failOnError" default="true" />
<element name="args" optional="n" />
<sequential>
<exec executable="${phpbin}" resultproperty="exec.res"
failonerror="@{failOnError}">
<args />
</exec>
<echo message="Exit code was ${exec.res}" />
</sequential>
</macrodef>
<macrodef name="call-php-using-filesets">
<attribute name="failOnError" default="true" />
<element name="args" optional="n" />
<sequential>
<apply executable="${phpbin}" resultproperty="exitcode"
failonerror="@{failOnError}">
<args />
</apply>
</sequential>
</macrodef>
<!-- ========================================================================================================= -->
<target name="build"
depends="prepare,lint,phploc-ci,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpunit,phpdox"
description="" />
<target name="build-parallel" depends="prepare,lint,tools-parallel,phpunit,phpdox"
description="" />
<target name="tools-parallel" description="Run tools in parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend" />
<antcall target="phpmd-ci" />
</sequential>
<antcall target="phpcpd-ci" />
<antcall target="phpcs-ci" />
<antcall target="phploc-ci" />
</parallel>
</target>
<!-- ========================================================================================================= -->
<target name="clean" unless="clean.done" description="Cleanup build artifacts">
<delete dir="${basedir}/build/api" />
<delete dir="${basedir}/build/coverage" />
<delete dir="${basedir}/build/docs-xml" />
<delete dir="${basedir}/build/logs" />
<delete dir="${basedir}/build/pdepend" />
<delete dir="${basedir}/build/phpdox" />
<delete dir="${basedir}/coverage" />
<delete dir="${basedir}/API_Documentation" />
<delete dir="${basedir}/docs" />
<property name="clean.done" value="true" />
</target>
<!-- ========================================================================================================= -->
<target name="prepare" unless="prepare.done" depends="clean"
description="Prepare for build">
<mkdir dir="${basedir}/build/api" />
<mkdir dir="${basedir}/build/coverage" />
<mkdir dir="${basedir}/build/docs-xml" />
<mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/pdepend" />
<mkdir dir="${basedir}/build/phpdox" />
<mkdir dir="${basedir}/docs" />
<property name="prepare.done" value="true" />
</target>
<!-- ========================================================================================================= -->
<!-- Retrieve composer.phar -->
<target name="get-composer" description="Retrieve composer from remote"
depends="prepare">
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/build/composer.phar" />
</target>
<!-- ========================================================================================================= -->
<!-- Update the dependencies using composer (enabled by default) -->
<target name="update-deps" depends="get-composer"
description="Runs build including updating depedendencies">
<call-php>
<args>
<arg value="${basedir}/build/composer.phar" />
<arg value="update" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="lint" description="Perform syntax check of sourcecode files">
<call-php-using-filesets>
<args>
<arg value="-l" />
<fileset dir="${basedir}/src">
<include name="**/*.php" />
<modified />
</fileset>
<fileset dir="${basedir}/tests">
<include name="**/*.php" />
<modified />
</fileset>
</args>
</call-php-using-filesets>
</target>
<!-- ========================================================================================================= -->
<target name="phploc" depends="update-deps"
description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
<call-php>
<args>
<arg path="${basedir}/vendor/phploc/phploc/phploc" />
<arg value="--count-tests" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</args>
</call-php>
</target>
<target name="phploc-ci" depends="update-deps"
description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
<call-php>
<args>
<arg path="${basedir}/vendor/phploc/phploc/phploc" />
<arg value="--count-tests" />
<arg value="--log-csv" />
<arg path="${basedir}/build/logs/phploc.csv" />
<arg value="--log-xml" />
<arg path="${basedir}/build/logs/phploc.xml" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="pdepend" depends="update-deps"
description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
<call-php failOnError="false">
<args>
<arg path="${basedir}/vendor/pdepend/pdepend/src/bin/pdepend" />
<arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg
value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg path="${basedir}/src" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="phpmd" depends="update-deps"
description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.">
<call-php>
<args>
<arg path="${basedir}/vendor/phpmd/phpmd/src/bin/phpmd" />
<arg path="${basedir}/src" />
<arg value="text" />
<arg path="${basedir}/phpmd.xml" />
</args>
</call-php>
</target>
<target name="phpmd-ci" depends="update-deps"
description="Perform project mess detection using PHPMD and log result in XML format. Intended for usage within a continuous integration environment.">
<call-php failOnError="false">
<args>
<arg path="${basedir}/vendor/phpmd/phpmd/src/bin/phpmd" />
<arg path="${basedir}/src" />
<arg value="xml" />
<arg path="${basedir}/phpmd.xml" />
<arg value="--reportfile" />
<arg path="${basedir}/build/logs/pmd.xml" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="phpcs" depends="update-deps"
description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
<call-php failOnError="false">
<args>
<arg path="${basedir}/vendor/squizlabs/php_codesniffer/bin/phpcs" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg value="--report=xml" />
<arg value="--report-file=build/logs/phpcs.log" />
<arg path="${basedir}/src" />
<arg path="${basedir}/tests" />
</args>
</call-php>
</target>
<target name="phpcs-ci" depends="update-deps"
description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
<call-php failOnError="false">
<args>
<arg path="${basedir}/vendor/squizlabs/php_codesniffer/bin/phpcs" />
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
<arg value="--standard=PSR2" />
<arg value="--extensions=php" />
<arg value="--ignore=autoload.php" />
<arg path="${basedir}/src" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="phpcpd" depends="update-deps"
description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
<call-php>
<args>
<arg path="${basedir}/vendor/sebastian/phpcpd/phpcpd" />
<arg path="${basedir}/src" />
</args>
</call-php>
</target>
<target name="phpcpd-ci" depends="update-deps"
description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
<call-php>
<args>
<arg path="${basedir}/vendor/sebastian/phpcpd/phpcpd" />
<arg value="--log-pmd" />
<arg path="${basedir}/build/logs/pmd-cpd.xml" />
<arg path="${basedir}/src" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="phpunit" depends="update-deps" description="Run unit tests with PHPUnit">
<call-php>
<args>
<arg path="${basedir}/vendor/phpunit/phpunit/phpunit" />
<arg value="--configuration" />
<arg path="${basedir}/phpunit.xml" />
<arg value="--coverage-clover" />
<arg path="${basedir}/build/logs/clover.xml" />
<arg value="--coverage-crap4j" />
<arg path="${basedir}/build/logs/crap4j.xml" />
<arg value="--log-junit" />
<arg path="${basedir}/build/logs/junit.xml" />
<arg value="--coverage-html" />
<arg path="${basedir}/build/logs/coverage/html" />
<arg value="--coverage-xml" />
<arg path="${basedir}/build/logs/coverage/xml" />
</args>
</call-php>
</target>
<!-- ========================================================================================================= -->
<target name="phpdox" depends="update-deps,phploc-ci,phpcs-ci,phpmd-ci,phpunit"
description="Generate project documentation using phpDox">
<call-php>
<args>
<arg path="${basedir}/vendor/theseer/phpdox/phpdox" />
</args>
</call-php>
</target>
</project>
|