build.xml 18 KB

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