build.xml 19 KB

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