build.xml 9.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="animeclient" default="full-build">
  3. <!-- By default, we assume all tools to be on the $PATH -->
  4. <property name="pdepend" value="pdepend"/>
  5. <property name="phpcpd" value="phpcpd"/>
  6. <property name="phpcs" value="phpcs"/>
  7. <property name="phploc" value="phploc"/>
  8. <property name="phpmd" value="phpmd"/>
  9. <property name="phpunit" value="phpunit"/>
  10. <!-- <property name="sonar" value="sonar-runner"/> -->
  11. <!-- Use this when the tools are located as PHARs in build/tools
  12. <property name="pdepend" value="build/tools/pdepend.phar"/>
  13. <property name="phpcpd" value="build/tools/phpcpd.phar"/>
  14. <property name="phpcs" value="build/tools/phpcs.phar"/>
  15. <property name="phpdox" value="build/tools/phpdox.phar"/>
  16. <property name="phploc" value="build/tools/phploc.phar"/>
  17. <property name="phpmd" value="build/tools/phpmd.phar"/>
  18. <property name="phpunit" value="build/tools/phpunit.phar"/> -->
  19. <!-- Use this when the tools are managed by Composer in vendor/bin
  20. <property name="pdepend" value="vendor/bin/pdepend"/>
  21. <property name="phpcpd" value="vendor/bin/phpcpd"/>
  22. <property name="phpcs" value="vendor/bin/phpcs"/>
  23. <property name="phpdox" value="vendor/bin/phpdox"/>
  24. <property name="phploc" value="vendor/bin/phploc"/>
  25. <property name="phpmd" value="vendor/bin/phpmd"/>
  26. <property name="phpunit" value="vendor/bin/phpunit"/> -->
  27. <target name="full-build"
  28. depends="prepare,static-analysis,phpunit,-check-failure"
  29. description="Performs static analysis, runs the tests, and generates project documentation"/>
  30. <target name="full-build-parallel"
  31. depends="prepare,static-analysis-parallel,phpunit, -check-failure"
  32. description="Performs static analysis (executing the tools in parallel), runs the tests, and generates project documentation"/>
  33. <target name="quick-build"
  34. depends="prepare,lint,phpunit-no-coverage"
  35. description="Performs a lint check and runs the tests (without generating code coverage reports)"/>
  36. <target name="static-analysis"
  37. depends="lint,phploc-ci,pdepend,phpcs-ci,phpcpd-ci"
  38. description="Performs static analysis" />
  39. <!-- Adjust the threadCount attribute's value to the number of CPUs -->
  40. <target name="static-analysis-parallel"
  41. description="Performs static analysis (executing the tools in parallel)">
  42. <parallel threadCount="2">
  43. <sequential>
  44. <antcall target="pdepend"/>
  45. </sequential>
  46. <antcall target="lint"/>
  47. <antcall target="phpcpd-ci"/>
  48. <antcall target="phpcs-ci"/>
  49. <antcall target="phploc-ci"/>
  50. </parallel>
  51. </target>
  52. <target name="clean"
  53. unless="clean.done"
  54. description="Cleanup build artifacts">
  55. <delete dir="build/api"/>
  56. <delete dir="build/coverage"/>
  57. <delete dir="build/logs"/>
  58. <delete dir="build/pdepend"/>
  59. <property name="clean.done" value="true"/>
  60. </target>
  61. <target name="prepare"
  62. unless="prepare.done"
  63. depends="clean"
  64. description="Prepare for build">
  65. <mkdir dir="build/api"/>
  66. <mkdir dir="build/coverage"/>
  67. <mkdir dir="build/logs"/>
  68. <mkdir dir="build/pdepend"/>
  69. <property name="prepare.done" value="true"/>
  70. </target>
  71. <target name="lint"
  72. unless="lint.done"
  73. description="Perform syntax check of sourcecode files">
  74. <apply executable="php" taskname="lint">
  75. <arg value="-l" />
  76. <fileset dir="application">
  77. <include name="**/*.php" />
  78. <exclude name="logs/*.php" />
  79. <exclude name="config/**/*.php" />
  80. <exclude name="errors/*.php" />
  81. <exclude name="third_party/**/*.php" />
  82. <exclude name="views/**/*.php" />
  83. <modified />
  84. </fileset>
  85. <fileset dir="tests">
  86. <include name="**/*.php" />
  87. <modified />
  88. </fileset>
  89. </apply>
  90. <property name="lint.done" value="true"/>
  91. </target>
  92. <target name="phploc"
  93. unless="phploc.done"
  94. description="Measure project size using PHPLOC and print human readable output. Intended for usage on the command line.">
  95. <exec executable="${phploc}" taskname="phploc">
  96. <arg value="--count-tests" />
  97. <arg path="application/controllers" />
  98. <arg path="application/models" />
  99. <arg path="application/libraries" />
  100. <arg path="application/core" />
  101. <arg path="application/hooks" />
  102. <arg path="tests" />
  103. </exec>
  104. <property name="phploc.done" value="true"/>
  105. </target>
  106. <target name="phploc-ci"
  107. unless="phploc.done"
  108. depends="prepare"
  109. description="Measure project size using PHPLOC and log result in CSV and XML format. Intended for usage within a continuous integration environment.">
  110. <exec executable="${phploc}" taskname="phploc">
  111. <arg value="--count-tests" />
  112. <arg value="--log-csv" />
  113. <arg path="build/logs/phploc.csv" />
  114. <arg value="--log-xml" />
  115. <arg path="build/logs/phploc.xml" />
  116. <arg path="application/controllers" />
  117. <arg path="application/models" />
  118. <arg path="application/libraries" />
  119. <arg path="application/core" />
  120. <arg path="application/hooks" />
  121. <arg path="tests" />
  122. </exec>
  123. <property name="phploc.done" value="true"/>
  124. </target>
  125. <target name="pdepend"
  126. unless="pdepend.done"
  127. depends="prepare"
  128. description="Calculate software metrics using PHP_Depend and log result in XML format. Intended for usage within a continuous integration environment.">
  129. <exec executable="${pdepend}" taskname="pdepend">
  130. <arg value="--jdepend-xml=build/logs/jdepend.xml" />
  131. <arg value="--jdepend-chart=build/pdepend/dependencies.svg" />
  132. <arg value="--overview-pyramid=build/pdepend/overview-pyramid.svg" />
  133. <arg path="application" />
  134. </exec>
  135. <property name="pdepend.done" value="true"/>
  136. </target>
  137. <target name="phpcs"
  138. unless="phpcs.done"
  139. description="Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.">
  140. <exec executable="${phpcs}" taskname="phpcs">
  141. <arg value="--standard=PSR2" />
  142. <arg value="--extensions=php" />
  143. <arg value="--ignore=autoload.php" />
  144. <arg path="application/controllers" />
  145. <arg path="application/models" />
  146. <arg path="application/libraries" />
  147. <arg path="application/core" />
  148. <arg path="application/hooks" />
  149. <arg path="tests" />
  150. </exec>
  151. <property name="phpcs.done" value="true"/>
  152. </target>
  153. <target name="phpcs-ci"
  154. unless="phpcs.done"
  155. depends="prepare"
  156. description="Find coding standard violations using PHP_CodeSniffer and log result in XML format. Intended for usage within a continuous integration environment.">
  157. <exec executable="${phpcs}" output="/dev/null" taskname="phpcs">
  158. <arg value="--report=checkstyle" />
  159. <arg value="--report-file=build/logs/checkstyle.xml" />
  160. <arg value="--standard=PSR2" />
  161. <arg value="--extensions=php" />
  162. <arg value="--ignore=autoload.php" />
  163. <arg path="application/controllers" />
  164. <arg path="application/models" />
  165. <arg path="application/libraries" />
  166. <arg path="application/core" />
  167. <arg path="application/hooks" />
  168. <arg path="tests" />
  169. </exec>
  170. <property name="phpcs.done" value="true"/>
  171. </target>
  172. <target name="phpcpd"
  173. unless="phpcpd.done"
  174. description="Find duplicate code using PHPCPD and print human readable output. Intended for usage on the command line before committing.">
  175. <exec executable="${phpcpd}" taskname="phpcpd">
  176. <arg path="application/controllers" />
  177. <arg path="application/models" />
  178. <arg path="application/libraries" />
  179. <arg path="application/core" />
  180. <arg path="application/hooks" />
  181. </exec>
  182. <property name="phpcpd.done" value="true"/>
  183. </target>
  184. <target name="phpcpd-ci"
  185. unless="phpcpd.done"
  186. depends="prepare"
  187. description="Find duplicate code using PHPCPD and log result in XML format. Intended for usage within a continuous integration environment.">
  188. <exec executable="${phpcpd}" taskname="phpcpd">
  189. <arg value="--log-pmd" />
  190. <arg path="build/logs/pmd-cpd.xml" />
  191. <arg path="application/controllers" />
  192. <arg path="application/models" />
  193. <arg path="application/libraries" />
  194. <arg path="application/core" />
  195. <arg path="application/hooks" />
  196. </exec>
  197. <property name="phpcpd.done" value="true"/>
  198. </target>
  199. <target name="phpunit"
  200. unless="phpunit.done"
  201. depends="prepare"
  202. description="Run unit tests with PHPUnit">
  203. <exec executable="${phpunit}" resultproperty="result.phpunit" taskname="phpunit">
  204. <arg value="--configuration"/>
  205. <arg path="build/phpunit.xml"/>
  206. </exec>
  207. <property name="phpunit.done" value="true"/>
  208. </target>
  209. <target name="phpunit-no-coverage"
  210. unless="phpunit.done"
  211. depends="prepare"
  212. description="Run unit tests with PHPUnit (without generating code coverage reports)">
  213. <exec executable="${phpunit}" failonerror="true" taskname="phpunit">
  214. <arg value="--configuration"/>
  215. <arg path="build/phpunit.xml"/>
  216. <arg value="--no-coverage"/>
  217. </exec>
  218. <property name="phpunit.done" value="true"/>
  219. </target>
  220. <!-- <target name="sonar"
  221. depends="phpunit">
  222. <exec executable="${sonar}" taskname="sonar"/>
  223. <property name="sonar.done" value="true"/>
  224. </target> -->
  225. <target name="-check-failure">
  226. <fail message="PHPUnit did not finish successfully">
  227. <condition>
  228. <not>
  229. <equals arg1="${result.phpunit}" arg2="0"/>
  230. </not>
  231. </condition>
  232. </fail>
  233. </target>
  234. </project>