build.xml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?xml version="1.0"?>
  2. <project name="DoctrineCommonCache" default="build" basedir=".">
  3. <property file="build.properties" />
  4. <target name="php">
  5. <exec executable="which" outputproperty="php_executable">
  6. <arg value="php" />
  7. </exec>
  8. </target>
  9. <target name="prepare">
  10. <mkdir dir="build" />
  11. </target>
  12. <target name="build" depends="check-git-checkout-clean,prepare,php,composer">
  13. <exec executable="${php_executable}">
  14. <arg value="build/composer.phar" />
  15. <arg value="archive" />
  16. <arg value="--dir=build" />
  17. </exec>
  18. </target>
  19. <target name="composer" depends="php,composer-check,composer-download">
  20. <exec executable="${php_executable}">
  21. <arg value="build/composer.phar" />
  22. <arg value="install" />
  23. </exec>
  24. </target>
  25. <target name="composer-check" depends="prepare">
  26. <available file="build/composer.phar" property="composer.present"/>
  27. </target>
  28. <target name="composer-download" unless="composer.present">
  29. <exec executable="wget">
  30. <arg value="-Obuild/composer.phar" />
  31. <arg value="http://getcomposer.org/composer.phar" />
  32. </exec>
  33. </target>
  34. <target name="make-release" depends="check-git-checkout-clean,prepare,php">
  35. <replace file="${project.version_file}" token="-DEV" value="" failOnNoReplacements="true" />
  36. <exec executable="git" failonerror="true" outputproperty="current_git_branch">
  37. <arg value="rev-parse" />
  38. <arg value="--abbrev-ref" />
  39. <arg value="HEAD" />
  40. </exec>
  41. <exec executable="${php_executable}" outputproperty="doctrine.current_version" failonerror="true">
  42. <arg value="-r" />
  43. <arg value="require_once '${project.version_file}';echo ${project.version_class}::VERSION;" />
  44. </exec>
  45. <exec executable="${php_executable}" outputproperty="doctrine.next_version" failonerror="true">
  46. <arg value="-r" />
  47. <arg value="$parts = explode('.', str_ireplace(array('-DEV', '-ALPHA', '-BETA'), '', '${doctrine.current_version}'));
  48. if (count($parts) != 3) {
  49. throw new \InvalidArgumentException('Version is assumed in format x.y.z, ${doctrine.current_version} given');
  50. }
  51. if ('${current_git_branch}' === 'master') {
  52. $parts[1]++;
  53. } else {
  54. $parts[2]++;
  55. }
  56. echo implode('.', $parts);
  57. " />
  58. </exec>
  59. <git-commit file="${project.version_file}" message="Release ${doctrine.current_version}" />
  60. <git-tag version="${doctrine.current_version}" />
  61. <replace file="${project.version_file}" token="${doctrine.current_version}" value="${doctrine.next_version}-DEV" />
  62. <git-commit file="${project.version_file}" message="Bump version to ${doctrine.next_version}" />
  63. </target>
  64. <target name="check-git-checkout-clean">
  65. <exec executable="git" failonerror="true">
  66. <arg value="diff-index" />
  67. <arg value="--quiet" />
  68. <arg value="HEAD" />
  69. </exec>
  70. </target>
  71. <macrodef name="git-commit">
  72. <attribute name="file" default="NOT SET"/>
  73. <attribute name="message" default="NOT SET"/>
  74. <sequential>
  75. <exec executable="git">
  76. <arg value="add" />
  77. <arg value="@{file}" />
  78. </exec>
  79. <exec executable="git">
  80. <arg value="commit" />
  81. <arg value="-m" />
  82. <arg value="@{message}" />
  83. </exec>
  84. </sequential>
  85. </macrodef>
  86. <macrodef name="git-tag">
  87. <attribute name="version" default="NOT SET" />
  88. <sequential>
  89. <exec executable="git">
  90. <arg value="tag" />
  91. <arg value="-m" />
  92. <arg value="v@{version}" />
  93. <arg value="v@{version}" />
  94. </exec>
  95. </sequential>
  96. </macrodef>
  97. </project>