build.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="phpunit" default="setup">
  3. <target name="setup" depends="clean,install-dependencies"/>
  4. <target name="validate" depends="php-syntax-check,validate-composer-json,validate-phpunit-xsd"/>
  5. <target name="clean" unless="clean.done" description="Cleanup build artifacts">
  6. <delete dir="${basedir}/bin"/>
  7. <delete dir="${basedir}/vendor"/>
  8. <delete file="${basedir}/composer.lock"/>
  9. <delete dir="${basedir}/build/documentation"/>
  10. <delete dir="${basedir}/build/logfiles"/>
  11. <delete dir="${basedir}/build/phar"/>
  12. <delete>
  13. <fileset dir="${basedir}/build">
  14. <include name="**/phpunit*.phar"/>
  15. <include name="**/phpunit*.phar.asc"/>
  16. </fileset>
  17. </delete>
  18. <property name="clean.done" value="true"/>
  19. </target>
  20. <target name="prepare" unless="prepare.done" depends="clean" description="Prepare for build">
  21. <mkdir dir="${basedir}/build/documentation"/>
  22. <mkdir dir="${basedir}/build/logfiles"/>
  23. <property name="prepare.done" value="true"/>
  24. </target>
  25. <target name="validate-composer-json" unless="validate-composer-json.done" description="Validate composer.json">
  26. <exec executable="${basedir}/build/tools/composer" failonerror="true" taskname="composer">
  27. <arg value="validate"/>
  28. <arg value="--no-check-lock"/>
  29. <arg value="--strict"/>
  30. <arg value="${basedir}/composer.json"/>
  31. </exec>
  32. <property name="validate-composer-json.done" value="true"/>
  33. </target>
  34. <target name="-dependencies-installed">
  35. <available file="${basedir}/composer.lock" property="dependencies-installed"/>
  36. </target>
  37. <target name="install-dependencies" unless="dependencies-installed" depends="-dependencies-installed,validate-composer-json" description="Install dependencies with Composer">
  38. <exec executable="${basedir}/build/tools/composer" taskname="composer">
  39. <arg value="update"/>
  40. <arg value="--no-interaction"/>
  41. <arg value="--no-progress"/>
  42. <arg value="--no-ansi"/>
  43. <arg value="--no-suggest"/>
  44. <arg value="--optimize-autoloader"/>
  45. <arg value="--prefer-stable"/>
  46. </exec>
  47. </target>
  48. <target name="php-syntax-check" unless="php-syntax-check.done" description="Perform syntax check on PHP files">
  49. <apply executable="php" failonerror="true" taskname="lint">
  50. <arg value="-l"/>
  51. <fileset dir="${basedir}/src">
  52. <include name="**/*.php"/>
  53. <modified/>
  54. </fileset>
  55. <fileset dir="${basedir}/tests">
  56. <include name="**/*.php"/>
  57. <modified/>
  58. </fileset>
  59. </apply>
  60. <property name="php-syntax-check.done" value="true"/>
  61. </target>
  62. <target name="validate-phpunit-xsd" unless="validate-phpunit-xsd.done" description="Validate phpunit.xsd">
  63. <exec executable="xmllint" failonerror="true" taskname="xmllint">
  64. <arg value="--noout"/>
  65. <arg path="${basedir}/phpunit.xsd"/>
  66. </exec>
  67. <property name="validate-phpunit-xsd.done" value="true"/>
  68. </target>
  69. <target name="test" depends="validate,install-dependencies" description="Run tests">
  70. <exec executable="${basedir}/phpunit" taskname="phpunit"/>
  71. </target>
  72. <target name="signed-phar" depends="phar" description="Create signed PHAR archive of PHPUnit and all its dependencies">
  73. <exec executable="gpg" failonerror="true">
  74. <arg value="--local-user"/>
  75. <arg value="sb@sebastian-bergmann.de"/>
  76. <arg value="--armor"/>
  77. <arg value="--detach-sign"/>
  78. <arg path="${basedir}/build/phpunit-library-${version}.phar"/>
  79. </exec>
  80. <exec executable="gpg" failonerror="true">
  81. <arg value="--local-user"/>
  82. <arg value="sb@sebastian-bergmann.de"/>
  83. <arg value="--armor"/>
  84. <arg value="--detach-sign"/>
  85. <arg path="${basedir}/build/phpunit-${version}.phar"/>
  86. </exec>
  87. </target>
  88. <target name="phar" depends="-phar-determine-version,-phar-prepare" description="Create PHAR archive of PHPUnit and all its dependencies">
  89. <antcall target="-phar-build">
  90. <param name="type" value="release"/>
  91. </antcall>
  92. </target>
  93. <target name="phar-nightly" depends="-phar-prepare" description="Create PHAR archive of PHPUnit and all its dependencies (nightly)">
  94. <antcall target="-phar-build">
  95. <param name="type" value="nightly"/>
  96. </antcall>
  97. </target>
  98. <target name="-phar-prepare" depends="clean,install-dependencies">
  99. <mkdir dir="${basedir}/build/phar"/>
  100. <copy file="${basedir}/composer.json" tofile="${basedir}/composer.json.bak"/>
  101. <exec executable="${basedir}/build/tools/composer">
  102. <arg value="require"/>
  103. <arg value="phpunit/php-invoker:~1.1"/>
  104. </exec>
  105. <move file="${basedir}/composer.json.bak" tofile="${basedir}/composer.json"/>
  106. <exec executable="${basedir}/build/phar-manifest.php" output="${basedir}/build/phar/manifest.txt"/>
  107. <copy todir="${basedir}/build/phar" file="${basedir}/build/ca.pem" />
  108. <copy file="${basedir}/vendor/phpunit/php-code-coverage/LICENSE" tofile="${basedir}/build/phar/php-code-coverage/LICENSE"/>
  109. <copy todir="${basedir}/build/phar/php-code-coverage">
  110. <fileset dir="${basedir}/vendor/phpunit/php-code-coverage/src">
  111. <include name="**/*" />
  112. </fileset>
  113. </copy>
  114. <copy file="${basedir}/vendor/phpunit/php-file-iterator/LICENSE" tofile="${basedir}/build/phar/php-file-iterator/LICENSE"/>
  115. <copy todir="${basedir}/build/phar/php-file-iterator">
  116. <fileset dir="${basedir}/vendor/phpunit/php-file-iterator/src">
  117. <include name="**/*.php" />
  118. </fileset>
  119. </copy>
  120. <copy file="${basedir}/vendor/phpunit/php-text-template/LICENSE" tofile="${basedir}/build/phar/php-text-template/LICENSE"/>
  121. <copy todir="${basedir}/build/phar/php-text-template">
  122. <fileset dir="${basedir}/vendor/phpunit/php-text-template/src">
  123. <include name="**/*.php" />
  124. </fileset>
  125. </copy>
  126. <copy file="${basedir}/vendor/phpunit/php-timer/LICENSE" tofile="${basedir}/build/phar/php-timer/LICENSE"/>
  127. <copy todir="${basedir}/build/phar/php-timer">
  128. <fileset dir="${basedir}/vendor/phpunit/php-timer/src">
  129. <include name="**/*.php" />
  130. </fileset>
  131. </copy>
  132. <copy file="${basedir}/vendor/phpunit/php-token-stream/LICENSE" tofile="${basedir}/build/phar/php-token-stream/LICENSE"/>
  133. <copy todir="${basedir}/build/phar/php-token-stream">
  134. <fileset dir="${basedir}/vendor/phpunit/php-token-stream/src">
  135. <include name="**/*.php" />
  136. </fileset>
  137. </copy>
  138. <copy file="${basedir}/vendor/phpunit/phpunit-mock-objects/LICENSE" tofile="${basedir}/build/phar/phpunit-mock-objects/LICENSE"/>
  139. <copy todir="${basedir}/build/phar/phpunit-mock-objects">
  140. <fileset dir="${basedir}/vendor/phpunit/phpunit-mock-objects/src">
  141. <include name="**/*" />
  142. </fileset>
  143. </copy>
  144. <copy file="${basedir}/vendor/sebastian/code-unit-reverse-lookup/LICENSE" tofile="${basedir}/build/phar/sebastian-code-unit-reverse-lookup/LICENSE"/>
  145. <copy todir="${basedir}/build/phar/sebastian-code-unit-reverse-lookup">
  146. <fileset dir="${basedir}/vendor/sebastian/code-unit-reverse-lookup/src">
  147. <include name="**/*.php" />
  148. </fileset>
  149. </copy>
  150. <copy file="${basedir}/vendor/sebastian/comparator/LICENSE" tofile="${basedir}/build/phar/sebastian-comparator/LICENSE"/>
  151. <copy todir="${basedir}/build/phar/sebastian-comparator">
  152. <fileset dir="${basedir}/vendor/sebastian/comparator/src">
  153. <include name="**/*.php" />
  154. </fileset>
  155. </copy>
  156. <copy file="${basedir}/vendor/sebastian/diff/LICENSE" tofile="${basedir}/build/phar/sebastian-diff/LICENSE"/>
  157. <copy todir="${basedir}/build/phar/sebastian-diff">
  158. <fileset dir="${basedir}/vendor/sebastian/diff/src">
  159. <include name="**/*.php" />
  160. </fileset>
  161. </copy>
  162. <copy file="${basedir}/vendor/sebastian/environment/LICENSE" tofile="${basedir}/build/phar/sebastian-environment/LICENSE"/>
  163. <copy todir="${basedir}/build/phar/sebastian-environment">
  164. <fileset dir="${basedir}/vendor/sebastian/environment/src">
  165. <include name="**/*.php" />
  166. </fileset>
  167. </copy>
  168. <copy file="${basedir}/vendor/sebastian/exporter/LICENSE" tofile="${basedir}/build/phar/sebastian-exporter/LICENSE"/>
  169. <copy todir="${basedir}/build/phar/sebastian-exporter">
  170. <fileset dir="${basedir}/vendor/sebastian/exporter/src">
  171. <include name="**/*.php" />
  172. </fileset>
  173. </copy>
  174. <copy file="${basedir}/vendor/sebastian/recursion-context/LICENSE" tofile="${basedir}/build/phar/sebastian-recursion-context/LICENSE"/>
  175. <copy todir="${basedir}/build/phar/sebastian-recursion-context">
  176. <fileset dir="${basedir}/vendor/sebastian/recursion-context/src">
  177. <include name="**/*.php" />
  178. </fileset>
  179. </copy>
  180. <copy file="${basedir}/vendor/sebastian/resource-operations/LICENSE" tofile="${basedir}/build/phar/sebastian-resource-operations/LICENSE"/>
  181. <copy todir="${basedir}/build/phar/sebastian-resource-operations">
  182. <fileset dir="${basedir}/vendor/sebastian/resource-operations/src">
  183. <include name="**/*.php" />
  184. </fileset>
  185. </copy>
  186. <copy file="${basedir}/vendor/sebastian/global-state/LICENSE" tofile="${basedir}/build/phar/sebastian-global-state/LICENSE"/>
  187. <copy todir="${basedir}/build/phar/sebastian-global-state">
  188. <fileset dir="${basedir}/vendor/sebastian/global-state/src">
  189. <include name="**/*.php" />
  190. </fileset>
  191. </copy>
  192. <copy file="${basedir}/vendor/sebastian/object-enumerator/LICENSE" tofile="${basedir}/build/phar/object-enumerator/LICENSE"/>
  193. <copy todir="${basedir}/build/phar/sebastian-object-enumerator">
  194. <fileset dir="${basedir}/vendor/sebastian/object-enumerator/src">
  195. <include name="**/*.php" />
  196. </fileset>
  197. </copy>
  198. <copy file="${basedir}/vendor/sebastian/object-reflector/LICENSE" tofile="${basedir}/build/phar/object-reflector/LICENSE"/>
  199. <copy todir="${basedir}/build/phar/sebastian-object-reflector">
  200. <fileset dir="${basedir}/vendor/sebastian/object-reflector/src">
  201. <include name="**/*.php" />
  202. </fileset>
  203. </copy>
  204. <copy file="${basedir}/vendor/sebastian/version/LICENSE" tofile="${basedir}/build/phar/sebastian-version/LICENSE"/>
  205. <copy todir="${basedir}/build/phar/sebastian-version">
  206. <fileset dir="${basedir}/vendor/sebastian/version/src">
  207. <include name="**/*.php" />
  208. </fileset>
  209. </copy>
  210. <copy file="${basedir}/vendor/doctrine/instantiator/LICENSE" tofile="${basedir}/build/phar/doctrine-instantiator/LICENSE"/>
  211. <copy todir="${basedir}/build/phar/doctrine-instantiator">
  212. <fileset dir="${basedir}/vendor/doctrine/instantiator/src">
  213. <include name="**/*.php" />
  214. </fileset>
  215. </copy>
  216. <copy todir="${basedir}/build/phar/php-invoker">
  217. <fileset dir="${basedir}/vendor/phpunit/php-invoker/src">
  218. <include name="**/*.php" />
  219. </fileset>
  220. </copy>
  221. <copy file="${basedir}/vendor/phpdocumentor/reflection-common/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-common/LICENSE"/>
  222. <copy todir="${basedir}/build/phar/phpdocumentor-reflection-common">
  223. <fileset dir="${basedir}/vendor/phpdocumentor/reflection-common/src">
  224. <include name="**/*.php" />
  225. </fileset>
  226. </copy>
  227. <copy file="${basedir}/vendor/phpdocumentor/reflection-docblock/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-reflection-docblock/LICENSE"/>
  228. <copy todir="${basedir}/build/phar/phpdocumentor-reflection-docblock">
  229. <fileset dir="${basedir}/vendor/phpdocumentor/reflection-docblock/src">
  230. <include name="**/*.php" />
  231. </fileset>
  232. </copy>
  233. <copy file="${basedir}/vendor/phpdocumentor/type-resolver/LICENSE" tofile="${basedir}/build/phar/phpdocumentor-type-resolver/LICENSE"/>
  234. <copy todir="${basedir}/build/phar/phpdocumentor-type-resolver">
  235. <fileset dir="${basedir}/vendor/phpdocumentor/type-resolver/src">
  236. <include name="**/*.php" />
  237. </fileset>
  238. </copy>
  239. <copy file="${basedir}/vendor/phpspec/prophecy/LICENSE" tofile="${basedir}/build/phar/phpspec-prophecy/LICENSE"/>
  240. <copy todir="${basedir}/build/phar/phpspec-prophecy">
  241. <fileset dir="${basedir}/vendor/phpspec/prophecy/src">
  242. <include name="**/*.php" />
  243. </fileset>
  244. </copy>
  245. <copy file="${basedir}/vendor/myclabs/deep-copy/LICENSE" tofile="${basedir}/build/phar/myclabs-deep-copy/LICENSE"/>
  246. <copy todir="${basedir}/build/phar/myclabs-deep-copy">
  247. <fileset dir="${basedir}/vendor/myclabs/deep-copy/src">
  248. <include name="**/*.php" />
  249. </fileset>
  250. </copy>
  251. <copy file="${basedir}/vendor/webmozart/assert/LICENSE" tofile="${basedir}/build/phar/webmozart-assert/LICENSE"/>
  252. <copy todir="${basedir}/build/phar/webmozart-assert">
  253. <fileset dir="${basedir}/vendor/webmozart/assert/src">
  254. <include name="**/*.php" />
  255. </fileset>
  256. </copy>
  257. <copy file="${basedir}/vendor/phar-io/manifest/LICENSE" tofile="${basedir}/build/phar/phar-io-manifest/LICENSE"/>
  258. <copy todir="${basedir}/build/phar/phar-io-manifest">
  259. <fileset dir="${basedir}/vendor/phar-io/manifest/src">
  260. <include name="**/*.php" />
  261. </fileset>
  262. </copy>
  263. <copy file="${basedir}/vendor/phar-io/version/LICENSE" tofile="${basedir}/build/phar/phar-io-version/LICENSE"/>
  264. <copy todir="${basedir}/build/phar/phar-io-version">
  265. <fileset dir="${basedir}/vendor/phar-io/version/src">
  266. <include name="**/*.php" />
  267. </fileset>
  268. </copy>
  269. <copy file="${basedir}/vendor/theseer/tokenizer/LICENSE" tofile="${basedir}/build/phar/theseer-tokenizer/LICENSE"/>
  270. <copy todir="${basedir}/build/phar/theseer-tokenizer">
  271. <fileset dir="${basedir}/vendor/theseer/tokenizer/src">
  272. <include name="**/*.php" />
  273. </fileset>
  274. </copy>
  275. </target>
  276. <target name="-phar-build" depends="-phar-determine-version">
  277. <copy todir="${basedir}/build/phar/phpunit">
  278. <fileset dir="${basedir}/src">
  279. <include name="**/*.php"/>
  280. <include name="**/*.tpl*"/>
  281. </fileset>
  282. </copy>
  283. <exec executable="${basedir}/build/phar-version.php" outputproperty="_version">
  284. <arg value="${version}"/>
  285. <arg value="${type}"/>
  286. </exec>
  287. <exec executable="${basedir}/build/tools/phpab" taskname="phpab">
  288. <arg value="--all" />
  289. <arg value="--static" />
  290. <arg value="--once" />
  291. <arg value="--phar" />
  292. <arg value="--hash" />
  293. <arg value="SHA-1" />
  294. <arg value="--output" />
  295. <arg path="${basedir}/build/phpunit-library-${_version}.phar" />
  296. <arg value="--template" />
  297. <arg path="${basedir}/build/library-phar-autoload.php.in" />
  298. <arg path="${basedir}/build/phar" />
  299. </exec>
  300. <copy file="${basedir}/build/binary-phar-autoload.php.in" tofile="${basedir}/build/binary-phar-autoload.php"/>
  301. <replace file="${basedir}/build/binary-phar-autoload.php" token="X.Y.Z" value="${_version}"/>
  302. <exec executable="${basedir}/build/tools/phpab" taskname="phpab">
  303. <arg value="--all" />
  304. <arg value="--nolower" />
  305. <arg value="--static" />
  306. <arg value="--phar" />
  307. <arg value="--hash" />
  308. <arg value="SHA-1" />
  309. <arg value="--output" />
  310. <arg path="${basedir}/build/phpunit-${_version}.phar" />
  311. <arg value="--template" />
  312. <arg path="${basedir}/build/binary-phar-autoload.php" />
  313. <arg path="${basedir}/build/phar" />
  314. </exec>
  315. <chmod file="${basedir}/build/phpunit-${_version}.phar" perm="ugo+rx"/>
  316. <delete dir="${basedir}/build/phar"/>
  317. <delete file="${basedir}/build/binary-phar-autoload.php"/>
  318. </target>
  319. <target name="-phar-determine-version">
  320. <exec executable="${basedir}/build/version.php" outputproperty="version" />
  321. </target>
  322. <target name="generate-project-documentation" depends="-phploc,-phpcs,-phpmd,-phpunit">
  323. <exec executable="${basedir}/build/tools/phpdox" dir="${basedir}/build" taskname="phpdox"/>
  324. </target>
  325. <target name="-phploc" depends="prepare">
  326. <exec executable="${basedir}/build/tools/phploc" output="/dev/null" taskname="phploc">
  327. <arg value="--count-tests"/>
  328. <arg value="--log-xml"/>
  329. <arg path="${basedir}/build/logfiles/phploc.xml"/>
  330. <arg path="${basedir}/src"/>
  331. <arg path="${basedir}/tests"/>
  332. </exec>
  333. </target>
  334. <target name="phpcs">
  335. <exec executable="${basedir}/build/tools/phpcs" taskname="phpcs">
  336. <arg value="--standard=${basedir}/build/phpcs.xml"/>
  337. <arg value="--extensions=php"/>
  338. <arg value="--cache"/>
  339. </exec>
  340. </target>
  341. <target name="-phpcs" depends="prepare">
  342. <exec executable="${basedir}/build/tools/phpcs" output="/dev/null" taskname="phpcs">
  343. <arg value="--standard=${basedir}/build/phpcs.xml"/>
  344. <arg value="--extensions=php"/>
  345. <arg value="--cache"/>
  346. <arg value="--report=checkstyle"/>
  347. <arg value="--report-file=${basedir}/build/logfiles/checkstyle.xml"/>
  348. </exec>
  349. </target>
  350. <target name="-phpmd" depends="prepare">
  351. <exec executable="${basedir}/build/tools/phpmd" taskname="phpmd">
  352. <arg path="${basedir}/src"/>
  353. <arg value="xml"/>
  354. <arg path="${basedir}/build/phpmd.xml"/>
  355. <arg value="--reportfile"/>
  356. <arg path="${basedir}/build/logfiles/pmd.xml"/>
  357. </exec>
  358. </target>
  359. <target name="-phpunit" depends="setup">
  360. <exec executable="${basedir}/phpunit" taskname="phpunit">
  361. <arg value="--coverage-xml"/>
  362. <arg path="${basedir}/build/logfiles/coverage"/>
  363. <arg value="--log-junit"/>
  364. <arg path="${basedir}/build/logfiles/junit.xml"/>
  365. </exec>
  366. </target>
  367. </project>