build.xml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project default="build">
  3. <!-- Set executables according to OS -->
  4. <condition property="phpunit" value="${basedir}/vendor/bin/phpunit.bat" else="${basedir}/vendor/bin/phpunit">
  5. <os family="windows" />
  6. </condition>
  7. <condition property="phpcs" value="${basedir}/vendor/bin/phpcs.bat" else="${basedir}/vendor/bin/phpcs">
  8. <os family="windows" />
  9. </condition>
  10. <condition property="parallel-lint" value="${basedir}/vendor/bin/parallel-lint.bat" else="${basedir}/vendor/bin/parallel-lint">
  11. <os family="windows" />
  12. </condition>
  13. <condition property="var-dump-check" value="${basedir}/vendor/bin/var-dump-check.bat" else="${basedir}/vendor/bin/var-dump-check">
  14. <os family="windows"/>
  15. </condition>
  16. <!-- Use colors in output can be disabled when calling ant with -Duse-colors=false -->
  17. <property name="use-colors" value="true" />
  18. <condition property="colors-arg.color" value="--colors" else="">
  19. <equals arg1="${use-colors}" arg2="true" />
  20. </condition>
  21. <condition property="colors-arg.no-colors" value="" else="--no-colors">
  22. <equals arg1="${use-colors}" arg2="true" />
  23. </condition>
  24. <!-- Targets -->
  25. <target name="prepare" description="Create build directory">
  26. <mkdir dir="${basedir}/build/logs" />
  27. </target>
  28. <target name="phplint" description="Check syntax errors in PHP files">
  29. <exec executable="${parallel-lint}" failonerror="true">
  30. <arg line='--exclude ${basedir}/vendor/' />
  31. <arg line='${colors-arg.no-colors}' />
  32. <arg line='${basedir}' />
  33. </exec>
  34. </target>
  35. <target name="var-dump-check" description="Check PHP files for forgotten variable dumps">
  36. <exec executable="${var-dump-check}" failonerror="true">
  37. <arg line='--exclude ${basedir}/vendor/' />
  38. <arg line='${colors-arg.no-colors}' />
  39. <arg line='${basedir}' />
  40. </exec>
  41. </target>
  42. <target name="phpcs" depends="prepare" description="Check PHP code style">
  43. <delete file="${basedir}/build/logs/checkstyle.xml" quiet="true" />
  44. <exec executable="${phpcs}">
  45. <arg line='--extensions=php' />
  46. <arg line='--standard="${basedir}/vendor/jakub-onderka/php-code-style/ruleset.xml"' />
  47. <arg line='--report-checkstyle="${basedir}/build/logs/checkstyle.xml"' />
  48. <arg line='--report-full' />
  49. <arg line='"${basedir}/src"' />
  50. </exec>
  51. </target>
  52. <target name="phpunit" depends="prepare" description="PHP unit">
  53. <delete file="${basedir}/build/logs/phpunit.xml" quiet="true" />
  54. <exec executable="${phpunit}">
  55. <arg line='--configuration ${basedir}/phpunit.xml' />
  56. <arg line='-d memory_limit=256M' />
  57. <arg line='--log-junit "${basedir}/build/logs/phpunit.xml"' />
  58. <arg line='${colors-arg.color}' />
  59. </exec>
  60. </target>
  61. <target name="phpunit-coverage" depends="prepare" description="PHP unit with code coverage">
  62. <delete file="${basedir}/build/logs/phpunit.xml" quiet="true" />
  63. <delete file="${basedir}/build/logs/clover.xml" quiet="true" />
  64. <delete dir="${basedir}/build/coverage" quiet="true" />
  65. <mkdir dir="${basedir}/build/coverage" />
  66. <exec executable="${phpunit}" failonerror="true">
  67. <arg line='--configuration ${basedir}/phpunit.xml' />
  68. <arg line='-d memory_limit=256M' />
  69. <arg line='--log-junit "${basedir}/build/logs/phpunit.xml"' />
  70. <arg line='--coverage-clover "${basedir}/build/logs/clover.xml"' />
  71. <arg line='--coverage-html "${basedir}/build/coverage/"' />
  72. <arg line='${colors-arg.color}' />
  73. </exec>
  74. </target>
  75. <target name="build" depends="phplint,var-dump-check,phpcs,phpunit" />
  76. </project>