-
-
Save warmans/2064398 to your computer and use it in GitHub Desktop.
Phing build.xml for Symfony2 projects
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project name="${projectName}" basedir="." default="build:main"> | |
<!-- Properties --> | |
<property name="dir.app" value="${project.basedir}/app" /> | |
<property name="dir.src" value="${project.basedir}/src" /> | |
<property name="dir.build" value="${project.basedir}/app/build" /> | |
<property name="dir.docs" value="${dir.build}/docs" /> | |
<property name="dir.docs.phpdoc" value="${dir.docs}/phpdoc" /> | |
<property name="dir.docs.docblox" value="${dir.docs}/docblox" /> | |
<property name="dir.reports" value="${dir.build}/logs" /> | |
<property name="dir.reports.pdepend" value="${dir.reports}/pdepend" /> | |
<property name="dir.reports.coverage" value="${dir.reports}/coverage" /> | |
<!-- Filesets --> | |
<fileset id="sourcecode" dir="${dir.src}"> | |
<include name="**/*.php" /> | |
</fileset> | |
<!-- Default target --> | |
<target name="build:main" | |
depends="build:clean, build:prepare, build:check, build:test, build:doc" | |
description="Run all test and build everything" /> | |
<!-- Doc target --> | |
<target name="build:doc" | |
depends="build:prepare, doc:phpdoc, doc:docblox" | |
description="Generates app API documentation." /> | |
<!-- Check target --> | |
<target name="build:check" | |
depends="check:cs, check:md, check:cpd, check:depend" | |
description="Analyzes app code." /> | |
<!-- Test target --> | |
<target name="build:test" | |
depends="test:unit" | |
description="Executes all tests.." /> | |
<!-- Project build clean --> | |
<target name="build:clean" description="Clean up build directories."> | |
<echo msg="Cleaning build directories ..." /> | |
<delete dir="${dir.build}" verbose="true" /> | |
</target> | |
<!-- Project build prepare --> | |
<target name="build:prepare" description="Create build directories."> | |
<echo msg="Creating build directories ..." /> | |
<mkdir dir="${dir.build}" /> | |
<mkdir dir="${dir.docs}" /> | |
<mkdir dir="${dir.docs.phpdoc}" /> | |
<mkdir dir="${dir.docs.docblox}" /> | |
<mkdir dir="${dir.reports}" /> | |
<mkdir dir="${dir.reports.coverage}" /> | |
<mkdir dir="${dir.reports.pdepend}" /> | |
</target> | |
<!-- PHPDOC API documentation target --> | |
<target name="doc:phpdoc" description="Generate API documentation."> | |
<echo msg="Generating API documentation with PHPDoc..." /> | |
<phpdoc title="${phing.project.name} :: API Documentation" | |
defaultpackagename="${phing.project.name}" | |
destdir="${dir.docs.phpdoc}" | |
output="HTML:Smarty:PHP" | |
sourcecode="yes"> | |
<fileset refid="sourcecode" /> | |
</phpdoc> | |
</target> | |
<!-- DocBlox API documentation target --> | |
<target name="doc:docblox" description="Generate API Documentation."> | |
<echo msg="Generating API Documentation with DocBlox ..." /> | |
<docblox title="${phing.project.name} :: API Documentation" | |
destdir="${dir.docs.docblox}" | |
quiet="false"> | |
<fileset refid="sourcecode" /> | |
</docblox> | |
</target> | |
<!-- Symfony2 code sniffer --> | |
<target name="check:cs" description="Checks coding standard."> | |
<echo msg="Checking coding standard ..." /> | |
<phpcodesniffer standard="Symfony2" | |
showSniffs="true" | |
showWarnings="true"> | |
<fileset refid="sourcecode" /> | |
<formatter type="checkstyle" outfile="${dir.reports}/checkstyle.xml" /> | |
</phpcodesniffer> | |
</target> | |
<!-- copy/paste detector --> | |
<target name="check:cpd" description="Checks similar code blocks."> | |
<echo msg="Checking similar code blocks ..." /> | |
<phpcpd> | |
<fileset refid="sourcecode" /> | |
<formatter type="pmd" outfile="${dir.reports}/pmd-cpd.xml" /> | |
</phpcpd> | |
</target> | |
<!-- Mess detector --> | |
<target name="check:md" description="Generate code metrics."> | |
<echo msg="Generating code metrics ..." /> | |
<phpmd rulesets="codesize,unusedcode"> | |
<fileset refid="sourcecode" /> | |
<formatter type="xml" outfile="${dir.reports}/pmd.xml" /> | |
</phpmd> | |
</target> | |
<!-- Code dependency --> | |
<target name="check:depend" description="Checks coupling and dependency."> | |
<echo msg="Checking coupling and dependency ..." /> | |
<phpdepend> | |
<fileset refid="sourcecode" /> | |
<logger type="jdepend-xml" outfile="${dir.reports.pdepend}/jdepend.xml" /> | |
<logger type="jdepend-chart" outfile="${dir.reports.pdepend}/dependencies.svg" /> | |
<logger type="overview-pyramid" outfile="${dir.reports.pdepend}/overview-pyramid.svg" /> | |
</phpdepend> | |
</target> | |
<!-- Unit tests --> | |
<target name="test:unit" description="Executes unit tests."> | |
<echo msg="Running unit tests ..." /> | |
<exec command="phpunit --log-junit ${dir.reports}/phpunit.xml --coverage-clover ${dir.reports.coverage}/clover.xml --coverage-html ${dir.reports.coverage}/ -c ${dir.app}"/> | |
</target> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment