build.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <project name="CakePHP" default="build">
  3. <!--
  4. Build.xml file for CakePHP
  5. Uses phing to create releases.
  6. Based off of build.xml in doctrine.
  7. Use the `release` task to update VERSION.txt, and create a new tag.
  8. -->
  9. <property file="build.properties" />
  10. <!-- Read the current version, so we can replace it -->
  11. <target name="current-version">
  12. <exec executable="php" outputProperty="version">
  13. <arg value="-r" />
  14. <arg value="$fh = file('./VERSION.txt'); echo array_pop($fh);" />
  15. </exec>
  16. </target>
  17. <!--
  18. Updates the local copy to the latest head.
  19. -->
  20. <target name="update-branch">
  21. <echo msg="Updating to latest master." />
  22. <exec executable="git pull">
  23. <arg value="${git.remote}" />
  24. <arg value="master" />
  25. </exec>
  26. </target>
  27. <!--
  28. Bump the version number and commit that.
  29. -->
  30. <target name="next-version" depends="current-version">
  31. <echo msg="Incrementing version." />
  32. <propertyprompt propertyName="release_version" defaultValue="${version}" promptText="Enter version to be released."/>
  33. <echo msg="$file = file_get_contents('./VERSION.txt'); $file = str_replace('${version}', '${release_version}', $file); file_put_contents('./VERSION.txt', $file);" />
  34. <exec executable="php">
  35. <arg value="-r" />
  36. <arg value="$file = file_get_contents('./VERSION.txt'); $file = str_replace('${version}', '${release_version}', $file); file_put_contents('./VERSION.txt', $file);" />
  37. </exec>
  38. <echo msg="Version number updated." />
  39. <property name="version" value="${release_version}" override="true" />
  40. </target>
  41. <!--
  42. Create the release commit that updates the version number and pushes the commits.
  43. -->
  44. <target name="release-commit" depends="update-branch,next-version">
  45. <echo msg="Creating new release commit" />
  46. <exec command="git add ./VERSION.txt" logoutput="true" checkreturn="true" />
  47. <exec command="git commit -m 'Update version number to ${release_version}'" logoutput="true" checkreturn="true" />
  48. <exec command="git tag -s ${release_version} -m 'CakePHP ${release_version}'" logoutput="true" checkreturn="true" />
  49. <propertyprompt propertyName="shipit" defaultValue="n" promptText="Ship the new commit and tag?" />
  50. <condition property="noshipit" value="1">
  51. <equals arg1="n" arg2="${shipit}" casesensitive="false" />
  52. </condition>
  53. <fail if="noshipit" msg="You said not to ship it." />
  54. <echo msg="Pushing commit and tag." />
  55. <exec command="git push ${git.remote}" logoutput="true" checkreturn="true" />
  56. <exec command="git push ${git.remote} ${release_version}" logoutput="true" checkreturn="true" />
  57. <echo msg="Push complete." />
  58. </target>
  59. <target name="codestyle" description="Check codestyle (human readable format)">
  60. <phpcodesniffer
  61. standard="CakePHP"
  62. allowedFileExtensions="php">
  63. <fileset refid="libs" />
  64. </phpcodesniffer>
  65. </target>
  66. <target name="reports-ci">
  67. <phpcodesniffer
  68. standard="CakePHP"
  69. allowedFileExtensions="php">
  70. <fileset refid="libs" />
  71. <formatter type="checkstyle" outfile="checkstyle.xml" />
  72. </phpcodesniffer>
  73. <phpcpd
  74. minLines="4"
  75. minTokens="50">
  76. <fileset refid="libs" />
  77. <formatter type="pmd" outfile="pmd-cpd.xml"/>
  78. </phpcpd>
  79. <phpdepend>
  80. <fileset refid="libs" />
  81. <logger type="jdepend-xml" outfile="jdepend.xml"/>
  82. </phpdepend>
  83. <phpmd rulesets="codesize,unusedcode,design">
  84. <fileset refid="libs" />
  85. <formatter type="xml" outfile="reports/pmd.html"/>
  86. </phpmd>
  87. </target>
  88. <!--
  89. Top level easy to type targets
  90. -->
  91. <target name="release" depends="release-commit" description="Release a new version of CakePHP" />
  92. <target name="code-reports" depends="reports-ci"
  93. description="Run the code reports, generating XML output for CI server use." />
  94. </project>