build.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="PHP_CodeCoverage" default="build">
  3. <property name="php" value="php"/>
  4. <property name="phpunit" value="phpunit"/>
  5. <target name="build"
  6. depends="prepare,lint,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd,phpunit,phpcb"/>
  7. <target name="build-parallel"
  8. depends="prepare,lint,tools-parallel,phpunit,phpcb"/>
  9. <target name="tools-parallel"
  10. description="Run tools in parallel">
  11. <parallel threadCount="2">
  12. <sequential>
  13. <antcall target="pdepend"/>
  14. <antcall target="phpmd-ci"/>
  15. </sequential>
  16. <antcall target="phpcpd"/>
  17. <antcall target="phpcs-ci"/>
  18. <antcall target="phploc"/>
  19. </parallel>
  20. </target>
  21. <target name="clean" description="Cleanup build artifacts">
  22. <delete dir="${basedir}/build/api"/>
  23. <delete dir="${basedir}/build/code-browser"/>
  24. <delete dir="${basedir}/build/coverage"/>
  25. <delete dir="${basedir}/build/logs"/>
  26. <delete dir="${basedir}/build/pdepend"/>
  27. </target>
  28. <target name="prepare" depends="clean,phpab"
  29. description="Prepare for build">
  30. <mkdir dir="${basedir}/build/api"/>
  31. <mkdir dir="${basedir}/build/code-browser"/>
  32. <mkdir dir="${basedir}/build/coverage"/>
  33. <mkdir dir="${basedir}/build/logs"/>
  34. <mkdir dir="${basedir}/build/pdepend"/>
  35. </target>
  36. <target name="phpab" description="Generate autoloader scripts">
  37. <exec executable="phpab">
  38. <arg value="--output" />
  39. <arg path="PHP/CodeCoverage/Autoload.php" />
  40. <arg value="--template" />
  41. <arg path="PHP/CodeCoverage/Autoload.php.in" />
  42. <arg value="--indent" />
  43. <arg value=" " />
  44. <arg path="PHP" />
  45. </exec>
  46. </target>
  47. <target name="lint">
  48. <apply executable="${php}" failonerror="true">
  49. <arg value="-l" />
  50. <fileset dir="${basedir}/PHP">
  51. <include name="**/*.php" />
  52. <modified />
  53. </fileset>
  54. <fileset dir="${basedir}/Tests">
  55. <include name="**/*.php" />
  56. <modified />
  57. </fileset>
  58. </apply>
  59. </target>
  60. <target name="phploc" description="Measure project size using PHPLOC">
  61. <exec executable="phploc">
  62. <arg value="--log-csv" />
  63. <arg value="${basedir}/build/logs/phploc.csv" />
  64. <arg path="${basedir}/PHP" />
  65. </exec>
  66. </target>
  67. <target name="pdepend"
  68. description="Calculate software metrics using PHP_Depend">
  69. <exec executable="pdepend">
  70. <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
  71. <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
  72. <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
  73. <arg path="${basedir}/PHP" />
  74. </exec>
  75. </target>
  76. <target name="phpmd"
  77. description="Perform project mess detection using PHPMD">
  78. <exec executable="phpmd">
  79. <arg path="${basedir}/PHP" />
  80. <arg value="text" />
  81. <arg value="${basedir}/build/phpmd.xml" />
  82. </exec>
  83. </target>
  84. <target name="phpmd-ci"
  85. description="Perform project mess detection using PHPMD">
  86. <exec executable="phpmd">
  87. <arg path="${basedir}/PHP" />
  88. <arg value="xml" />
  89. <arg value="${basedir}/build/phpmd.xml" />
  90. <arg value="--reportfile" />
  91. <arg value="${basedir}/build/logs/pmd.xml" />
  92. </exec>
  93. </target>
  94. <target name="phpcs"
  95. description="Find coding standard violations using PHP_CodeSniffer">
  96. <exec executable="phpcs">
  97. <arg value="--standard=${basedir}/build/PHPCS" />
  98. <arg value="--extensions=php" />
  99. <arg value="--ignore=Autoload.php" />
  100. <arg path="${basedir}/PHP" />
  101. <arg path="${basedir}/Tests" />
  102. </exec>
  103. </target>
  104. <target name="phpcs-ci"
  105. description="Find coding standard violations using PHP_CodeSniffer">
  106. <exec executable="phpcs" output="/dev/null">
  107. <arg value="--report=checkstyle" />
  108. <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
  109. <arg value="--standard=${basedir}/build/PHPCS" />
  110. <arg value="--extensions=php" />
  111. <arg value="--ignore=Autoload.php" />
  112. <arg path="${basedir}/PHP" />
  113. <arg path="${basedir}/Tests" />
  114. </exec>
  115. </target>
  116. <target name="phpcpd" description="Find duplicate code using PHPCPD">
  117. <exec executable="phpcpd">
  118. <arg value="--log-pmd" />
  119. <arg value="${basedir}/build/logs/pmd-cpd.xml" />
  120. <arg path="${basedir}/PHP" />
  121. </exec>
  122. </target>
  123. <target name="phpunit" description="Run unit tests with PHPUnit">
  124. <condition property="phpunit_cmd" value="${php} ${phpunit}" else="${phpunit}">
  125. <not>
  126. <equals arg1="${phpunit}" arg2="phpunit" />
  127. </not>
  128. </condition>
  129. <exec executable="${phpunit_cmd}" failonerror="true"/>
  130. </target>
  131. <target name="phpcb"
  132. description="Aggregate tool output with PHP_CodeBrowser">
  133. <exec executable="phpcb">
  134. <arg value="--log" />
  135. <arg path="${basedir}/build/logs" />
  136. <arg value="--source" />
  137. <arg path="${basedir}/PHP" />
  138. <arg value="--output" />
  139. <arg path="${basedir}/build/code-browser" />
  140. </exec>
  141. </target>
  142. </project>