|
| 1 | +<?xml version="1.0" encoding="UTF-8"?> |
| 2 | + |
| 3 | + |
| 4 | +<project name="Onion" default="build"> |
| 5 | + |
| 6 | + <taskdef resource="net/sf/antcontrib/antlib.xml"/> |
| 7 | + |
| 8 | + <target name="build" |
| 9 | + depends="prepare,bundle,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpdox,phpunit,phpcb,package"/> |
| 10 | + |
| 11 | + <target name="build-parallel" |
| 12 | + depends="prepare,lint,tools-parallel,phpunit,phpcb"/> |
| 13 | + |
| 14 | + <target name="tools-parallel" description="Run tools in parallel"> |
| 15 | + <parallel threadCount="2"> |
| 16 | + <sequential> |
| 17 | + <antcall target="pdepend"/> |
| 18 | + <antcall target="phpmd-ci"/> |
| 19 | + </sequential> |
| 20 | + <antcall target="phpcpd"/> |
| 21 | + <antcall target="phpcs-ci"/> |
| 22 | + <antcall target="phploc"/> |
| 23 | + <antcall target="phpdox"/> |
| 24 | + </parallel> |
| 25 | + </target> |
| 26 | + |
| 27 | + <target name="clean" description="Cleanup build artifacts"> |
| 28 | + <delete dir="${basedir}/build/api"/> |
| 29 | + <delete dir="${basedir}/build/code-browser"/> |
| 30 | + <delete dir="${basedir}/build/coverage"/> |
| 31 | + <delete dir="${basedir}/build/logs"/> |
| 32 | + <delete dir="${basedir}/build/pdepend"/> |
| 33 | + </target> |
| 34 | + |
| 35 | + <target name="prepare" depends="clean" description="Prepare for build"> |
| 36 | + <mkdir dir="${basedir}/build/api"/> |
| 37 | + <mkdir dir="${basedir}/build/code-browser"/> |
| 38 | + <mkdir dir="${basedir}/build/coverage"/> |
| 39 | + <mkdir dir="${basedir}/build/logs"/> |
| 40 | + <mkdir dir="${basedir}/build/pdepend"/> |
| 41 | + <mkdir dir="${basedir}/build/phpdox"/> |
| 42 | + </target> |
| 43 | + |
| 44 | + <target name="lint" description="Perform syntax check of sourcecode files"> |
| 45 | + <apply executable="php" failonerror="true"> |
| 46 | + <arg value="-l" /> |
| 47 | + |
| 48 | + <fileset dir="${basedir}/src"> |
| 49 | + <include name="**/*.php" /> |
| 50 | + <modified /> |
| 51 | + </fileset> |
| 52 | + |
| 53 | + <fileset dir="${basedir}/tests"> |
| 54 | + <include name="**/*.php" /> |
| 55 | + <modified /> |
| 56 | + </fileset> |
| 57 | + </apply> |
| 58 | + </target> |
| 59 | + |
| 60 | + <target name="phploc" description="Measure project size using PHPLOC"> |
| 61 | + <exec executable="phploc"> |
| 62 | + <arg value="--log-csv" /> |
| 63 | + <arg value="${basedir}/build/logs/phploc.csv" /> |
| 64 | + <arg path="${basedir}/src" /> |
| 65 | + </exec> |
| 66 | + </target> |
| 67 | + |
| 68 | + <target name="pdepend" description="Calculate software metrics using PHP_Depend"> |
| 69 | + <exec executable="pdepend"> |
| 70 | + <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" /> |
| 71 | + <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" /> |
| 72 | + <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" /> |
| 73 | + <arg path="${basedir}/src" /> |
| 74 | + </exec> |
| 75 | + </target> |
| 76 | + |
| 77 | + <target name="phpmd" |
| 78 | + description="Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing."> |
| 79 | + <exec executable="phpmd"> |
| 80 | + <arg path="${basedir}/src" /> |
| 81 | + <arg value="text" /> |
| 82 | + <arg value="${basedir}/build/phpmd.xml" /> |
| 83 | + </exec> |
| 84 | + </target> |
| 85 | + |
| 86 | + <target name="phpmd-ci" description="Perform project mess detection using PHPMD creating a log file for the continuous integration server"> |
| 87 | + <exec executable="phpmd"> |
| 88 | + <arg path="${basedir}/src" /> |
| 89 | + <arg value="xml" /> |
| 90 | + <arg value="${basedir}/build/phpmd.xml" /> |
| 91 | + <arg value="--reportfile" /> |
| 92 | + <arg value="${basedir}/build/logs/pmd.xml" /> |
| 93 | + </exec> |
| 94 | + </target> |
| 95 | + |
| 96 | + <target name="phpcs" |
| 97 | + description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing."> |
| 98 | + <exec executable="phpcs"> |
| 99 | + <arg value="--standard=${basedir}/build/phpcs.xml" /> |
| 100 | + <arg path="${basedir}/src" /> |
| 101 | + </exec> |
| 102 | + </target> |
| 103 | + |
| 104 | + <target name="phpcs-ci" description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server"> |
| 105 | + <exec executable="phpcs" output="/dev/null"> |
| 106 | + <arg value="--report=checkstyle" /> |
| 107 | + <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" /> |
| 108 | + <arg value="--standard=${basedir}/build/phpcs.xml" /> |
| 109 | + <arg path="${basedir}/src" /> |
| 110 | + </exec> |
| 111 | + </target> |
| 112 | + |
| 113 | + <target name="phpcpd" description="Find duplicate code using PHPCPD"> |
| 114 | + <exec executable="phpcpd"> |
| 115 | + <arg value="--log-pmd" /> |
| 116 | + <arg value="${basedir}/build/logs/pmd-cpd.xml" /> |
| 117 | + <arg path="${basedir}/src" /> |
| 118 | + </exec> |
| 119 | + </target> |
| 120 | + |
| 121 | + <target name="phpdox" description="Generate API documentation using phpDox"> |
| 122 | + <exec executable="phpdox"/> |
| 123 | + </target> |
| 124 | + |
| 125 | + <target name="bundle"> |
| 126 | + <if> |
| 127 | + <available file="package.ini"/> |
| 128 | + <then> |
| 129 | + <exec executable="onion" failonerror="true"> |
| 130 | + <arg value="-q"/> |
| 131 | + <arg value="bundle"/> |
| 132 | + </exec> |
| 133 | + </then> |
| 134 | + </if> |
| 135 | + </target> |
| 136 | + |
| 137 | + <target name="package"> |
| 138 | + <if> |
| 139 | + <available file="scripts/compile.sh"/> |
| 140 | + <then> |
| 141 | + <exec executable="bash" failonerror="true"> |
| 142 | + <arg value="scripts/compile.sh"/> |
| 143 | + </exec> |
| 144 | + </then> |
| 145 | + </if> |
| 146 | + <if> |
| 147 | + <available file="package.ini"/> |
| 148 | + <then> |
| 149 | + <exec executable="onion" failonerror="true"> |
| 150 | + <arg value="-d"/> |
| 151 | + <arg value="build"/> |
| 152 | + </exec> |
| 153 | + </then> |
| 154 | + </if> |
| 155 | + </target> |
| 156 | + |
| 157 | + <!-- may we have a simple condition for phpunit.xml and phpunit-ci.xml ? --> |
| 158 | + <target name="phpunit" description="Run unit tests with PHPUnit"> |
| 159 | + |
| 160 | + <if> |
| 161 | + <available file="phpunit-ci.xml"/> |
| 162 | + <then> |
| 163 | + <exec executable="phpunit" failonerror="true"> |
| 164 | + <arg value="--configuration"/> |
| 165 | + <arg value="${basedir}/phpunit-ci.xml"/> |
| 166 | + </exec> |
| 167 | + </then> |
| 168 | + <else> |
| 169 | + <exec executable="phpunit" failonerror="true"/> |
| 170 | + </else> |
| 171 | + </if> |
| 172 | + |
| 173 | + </target> |
| 174 | + |
| 175 | + <target name="phpcb" description="Aggregate tool output with PHP_CodeBrowser"> |
| 176 | + <exec executable="phpcb"> |
| 177 | + <arg value="--log" /> |
| 178 | + <arg path="${basedir}/build/logs" /> |
| 179 | + <arg value="--source" /> |
| 180 | + <arg path="${basedir}/src" /> |
| 181 | + <arg value="--output" /> |
| 182 | + <arg path="${basedir}/build/code-browser" /> |
| 183 | + </exec> |
| 184 | + </target> |
| 185 | +</project> |
0 commit comments