build.xml 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="PHPUnit" default="build">
  3. <property name="php" value="php"/>
  4. <target name="build"
  5. depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpdox"/>
  6. <target name="clean" description="Cleanup build artifacts">
  7. <delete dir="${basedir}/bin"/>
  8. <delete dir="${basedir}/vendor"/>
  9. <delete file="${basedir}/composer.lock"/>
  10. <delete file="${basedir}/composer.phar"/>
  11. <delete dir="${basedir}/build/api"/>
  12. <delete dir="${basedir}/build/code-browser"/>
  13. <delete dir="${basedir}/build/coverage"/>
  14. <delete dir="${basedir}/build/logs"/>
  15. <delete dir="${basedir}/build/pdepend"/>
  16. <delete dir="${basedir}/build/phar"/>
  17. <delete>
  18. <fileset dir="${basedir}/build">
  19. <include name="**/*.phar" />
  20. </fileset>
  21. </delete>
  22. </target>
  23. <target name="prepare" depends="clean,phpab"
  24. description="Prepare for build">
  25. <mkdir dir="${basedir}/build/api"/>
  26. <mkdir dir="${basedir}/build/code-browser"/>
  27. <mkdir dir="${basedir}/build/coverage"/>
  28. <mkdir dir="${basedir}/build/logs"/>
  29. <mkdir dir="${basedir}/build/pdepend"/>
  30. <mkdir dir="${basedir}/build/phpdox"/>
  31. </target>
  32. <target name="phpab" description="Generate autoloader scripts">
  33. <exec executable="phpab">
  34. <arg value="--output" />
  35. <arg path="PHPUnit/Autoload.php" />
  36. <arg value="--template" />
  37. <arg path="PHPUnit/Autoload.php.in" />
  38. <arg value="--indent" />
  39. <arg value=" " />
  40. <arg path="PHPUnit" />
  41. </exec>
  42. </target>
  43. <target name="lint">
  44. <apply executable="${php}" failonerror="true">
  45. <arg value="-l" />
  46. <fileset dir="${basedir}/PHPUnit">
  47. <include name="**/*.php" />
  48. <modified />
  49. </fileset>
  50. <fileset dir="${basedir}/Tests">
  51. <include name="**/*.php" />
  52. <modified />
  53. </fileset>
  54. </apply>
  55. </target>
  56. <target name="phploc" description="Measure project size using PHPLOC">
  57. <exec executable="phploc">
  58. <arg value="--log-csv" />
  59. <arg value="${basedir}/build/logs/phploc.csv" />
  60. <arg value="--log-xml" />
  61. <arg value="${basedir}/build/logs/phploc.xml" />
  62. <arg path="${basedir}/PHPUnit" />
  63. </exec>
  64. </target>
  65. <target name="pdepend"
  66. description="Calculate software metrics using PHP_Depend">
  67. <exec executable="pdepend">
  68. <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
  69. <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
  70. <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
  71. <arg path="${basedir}/PHPUnit" />
  72. </exec>
  73. </target>
  74. <target name="phpmd"
  75. description="Perform project mess detection using PHPMD">
  76. <exec executable="phpmd">
  77. <arg path="${basedir}/PHPUnit" />
  78. <arg value="text" />
  79. <arg value="${basedir}/build/phpmd.xml" />
  80. </exec>
  81. </target>
  82. <target name="phpmd-ci"
  83. description="Perform project mess detection using PHPMD">
  84. <exec executable="phpmd">
  85. <arg path="${basedir}/PHPUnit" />
  86. <arg value="xml" />
  87. <arg value="${basedir}/build/phpmd.xml" />
  88. <arg value="--reportfile" />
  89. <arg value="${basedir}/build/logs/pmd.xml" />
  90. </exec>
  91. </target>
  92. <target name="phpcs"
  93. description="Find coding standard violations using PHP_CodeSniffer">
  94. <exec executable="phpcs">
  95. <arg value="--standard=${basedir}/build/PHPCS" />
  96. <arg value="--extensions=php" />
  97. <arg value="--ignore=Autoload.php" />
  98. <arg path="${basedir}/PHPUnit" />
  99. <arg path="${basedir}/Tests" />
  100. </exec>
  101. </target>
  102. <target name="phpcs-ci"
  103. description="Find coding standard violations using PHP_CodeSniffer">
  104. <exec executable="phpcs" output="/dev/null">
  105. <arg value="--report=checkstyle" />
  106. <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
  107. <arg value="--standard=${basedir}/build/PHPCS" />
  108. <arg value="--extensions=php" />
  109. <arg value="--ignore=Autoload.php" />
  110. <arg path="${basedir}/PHPUnit" />
  111. <arg path="${basedir}/Tests" />
  112. </exec>
  113. </target>
  114. <target name="phpcpd" description="Find duplicate code using PHPCPD">
  115. <exec executable="phpcpd">
  116. <arg value="--log-pmd" />
  117. <arg value="${basedir}/build/logs/pmd-cpd.xml" />
  118. <arg path="${basedir}/PHPUnit" />
  119. </exec>
  120. </target>
  121. <target name="phpunit" description="Run unit tests with PHPUnit">
  122. <exec executable="${php}" failonerror="true">
  123. <arg path="${basedir}/phpunit.php" />
  124. </exec>
  125. </target>
  126. <target name="phpdox"
  127. description="Generate software project documentation using phpDox">
  128. <exec executable="phpdox" />
  129. </target>
  130. <target name="phar"
  131. description="Create PHAR archive of PHPUnit and all its dependencies"
  132. depends="phar-prepare,phar-build">
  133. </target>
  134. <target name="phar-prepare" depends="clean">
  135. <mkdir dir="${basedir}/build/phar"/>
  136. <get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar"/>
  137. <exec executable="php">
  138. <arg value="composer.phar"/>
  139. <arg value="install"/>
  140. </exec>
  141. <copy file="${basedir}/composer.json" tofile="${basedir}/composer.json.bak"/>
  142. <exec executable="php">
  143. <arg value="composer.phar"/>
  144. <arg value="require"/>
  145. <arg value="phpunit/dbunit"/>
  146. <arg value="1.3.*"/>
  147. </exec>
  148. <exec executable="php">
  149. <arg value="composer.phar"/>
  150. <arg value="require"/>
  151. <arg value="phpunit/phpunit-selenium"/>
  152. <arg value="1.3.*"/>
  153. </exec>
  154. <exec executable="php">
  155. <arg value="composer.phar"/>
  156. <arg value="require"/>
  157. <arg value="phpunit/php-invoker"/>
  158. <arg value="1.1.*"/>
  159. </exec>
  160. <move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
  161. <copy todir="${basedir}/build/phar/php-code-coverage">
  162. <fileset dir="${basedir}/vendor/phpunit/php-code-coverage/PHP">
  163. <include name="**/*" />
  164. <exclude name="**/Autoload.*" />
  165. </fileset>
  166. </copy>
  167. <copy todir="${basedir}/build/phar/php-file-iterator">
  168. <fileset dir="${basedir}/vendor/phpunit/php-file-iterator/File">
  169. <include name="**/*.php" />
  170. <exclude name="**/Autoload.*" />
  171. </fileset>
  172. </copy>
  173. <copy todir="${basedir}/build/phar/php-text-template">
  174. <fileset dir="${basedir}/vendor/phpunit/php-text-template/Text">
  175. <include name="**/*.php" />
  176. <exclude name="**/Autoload.*" />
  177. </fileset>
  178. </copy>
  179. <copy todir="${basedir}/build/phar/php-timer">
  180. <fileset dir="${basedir}/vendor/phpunit/php-timer/PHP">
  181. <include name="**/*.php" />
  182. <exclude name="**/Autoload.*" />
  183. </fileset>
  184. </copy>
  185. <copy todir="${basedir}/build/phar/php-token-stream">
  186. <fileset dir="${basedir}/vendor/phpunit/php-token-stream/PHP">
  187. <include name="**/*.php" />
  188. <exclude name="**/Autoload.*" />
  189. </fileset>
  190. </copy>
  191. <copy todir="${basedir}/build/phar/phpunit-mock-objects">
  192. <fileset dir="${basedir}/vendor/phpunit/phpunit-mock-objects/PHPUnit">
  193. <include name="**/*" />
  194. <exclude name="**/Autoload.*" />
  195. </fileset>
  196. </copy>
  197. <copy todir="${basedir}/build/phar/symfony">
  198. <fileset dir="${basedir}/vendor/symfony">
  199. <include name="**/*.php" />
  200. <exclude name="**/Tests/**" />
  201. </fileset>
  202. </copy>
  203. <copy todir="${basedir}/build/phar/pear">
  204. <fileset dir="${basedir}/vendor/pear-pear.php.net">
  205. <include name="**/*.php" />
  206. </fileset>
  207. </copy>
  208. <copy todir="${basedir}/build/phar/dbunit">
  209. <fileset dir="${basedir}/vendor/phpunit/dbunit/PHPUnit">
  210. <include name="**/*.php" />
  211. <exclude name="**/Autoload.*" />
  212. </fileset>
  213. </copy>
  214. <copy todir="${basedir}/build/phar/php-invoker">
  215. <fileset dir="${basedir}/vendor/phpunit/php-invoker/PHP">
  216. <include name="**/*.php" />
  217. <exclude name="**/Autoload.*" />
  218. </fileset>
  219. </copy>
  220. <copy todir="${basedir}/build/phar/phpunit-selenium">
  221. <fileset dir="${basedir}/vendor/phpunit/phpunit-selenium/PHPUnit">
  222. <include name="**/*.php" />
  223. <exclude name="**/Autoload.*" />
  224. </fileset>
  225. </copy>
  226. </target>
  227. <target name="phar-build">
  228. <exec executable="bash" outputproperty="version">
  229. <arg value="-c" />
  230. <arg value="${basedir}/phpunit.php --version | awk 'BEGIN { ORS = &quot;&quot;; } {print $2}'" />
  231. </exec>
  232. <copy todir="${basedir}/build/phar/phpunit">
  233. <fileset dir="${basedir}/PHPUnit">
  234. <include name="**/*.php" />
  235. <include name="**/*.tpl*" />
  236. <exclude name="**/Autoload.*" />
  237. </fileset>
  238. </copy>
  239. <exec executable="phpab">
  240. <arg value="--all" />
  241. <arg value="--phar" />
  242. <arg value="--output" />
  243. <arg path="${basedir}/build/phpunit-${version}.phar" />
  244. <arg value="--template" />
  245. <arg path="${basedir}/build/phar-autoload.php.in" />
  246. <arg value="--indent" />
  247. <arg value=" " />
  248. <arg path="${basedir}/build/phar" />
  249. </exec>
  250. <chmod file="${basedir}/build/phpunit-${version}.phar" perm="ugo+rx"/>
  251. </target>
  252. </project>