build.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <project name="CakePHP" default="build">
  3. <taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
  4. <property file="build.properties" />
  5. <property name="package" value="${phing.project.name}" override="true" />
  6. <!--
  7. The set of files we're going to package
  8. Exclude the cli scripts, as they get installed separately.
  9. -->
  10. <fileset id="libs" dir="./lib/Cake">
  11. <include name="**" />
  12. <exclude name="Console/cake.bat" />
  13. <exclude name="Console/cake.php" />
  14. <exclude name="Console/cake" />
  15. </fileset>
  16. <!--
  17. CLI scripts to package and install
  18. -->
  19. <fileset id="cli" dir="./lib/Cake/Console">
  20. <include name="cake.bat" />
  21. <include name="cake.php" />
  22. <include name="cake" />
  23. </fileset>
  24. <!-- start fresh each time. Remove the dist and build dirs -->
  25. <target name="clean">
  26. <delete dir="${build.dir}" includeemptydirs="true" />
  27. <delete dir="${dist.dir}" includeemptydirs="true" />
  28. </target>
  29. <!-- makes directories and sets properties -->
  30. <target name="prepare" depends="clean">
  31. <echo msg="Creating build + dist directories." />
  32. <mkdir dir="${build.dir}" />
  33. <mkdir dir="${dist.dir}" />
  34. <exec executable="php" outputProperty="version">
  35. <arg value="-r" />
  36. <arg value="$fh = file('./lib/Cake/VERSION.txt'); echo array_pop($fh);" />
  37. </exec>
  38. <!-- set PEAR stability based on version number. -->
  39. <condition property="pear.stability" value="beta">
  40. <contains string="${version}" substring="beta" casesensitive="false"/>
  41. </condition>
  42. <condition property="pear.stability" value="alpha">
  43. <contains string="${version}" substring="alpha" casesensitive="false"/>
  44. </condition>
  45. <condition property="pear.stability" value="devel">
  46. <contains string="${version}" substring="dev" casesensitive="false"/>
  47. </condition>
  48. <condition property="pear.stability" value="beta">
  49. <contains string="${version}" substring="rc" casesensitive="false" />
  50. </condition>
  51. <condition property="pear.stability" value="stable">
  52. <not><isset property="pear.stability"/></not>
  53. </condition>
  54. <!-- pear versions need to not have '-' -->
  55. <exec executable="php" outputProperty="pear.version">
  56. <arg value="-r" />
  57. <arg value="echo str_replace(array('-'), array(''), '${version}');" />
  58. </exec>
  59. <echo msg="Preparing package of ${version} (${pear.version}+${pear.stability})" />
  60. </target>
  61. <!--
  62. Copy all the files to build/ so they can be packaged up.
  63. -->
  64. <target name="copy-files" depends="prepare">
  65. <echo msg="Copying files to build directory" />
  66. <copy todir="${build.dir}/${project.name}-${version}/Cake">
  67. <fileset refid="libs" />
  68. </copy>
  69. <copy todir="${build.dir}/${project.name}-${version}/bin">
  70. <fileset refid="cli" />
  71. </copy>
  72. </target>
  73. <!--
  74. Define the package.xml. Using xml to make xml is fun!
  75. -->
  76. <target name="define-pear-package" depends="copy-files">
  77. <d51pearpkg2 baseinstalldir="/" dir="${build.dir}/${project.name}-${version}">
  78. <name>CakePHP</name>
  79. <summary>CakePHP Framework</summary>
  80. <channel>pear.php.net</channel>
  81. <description>CakePHP </description>
  82. <lead user="mark_story" name="Mark Story" email="mark@mark-story.com" />
  83. <lead user="lorenzo" name="José Lorenzo Rodríguez" email="jose.zap@gmail.com" />
  84. <lead user="PhpNut" name="Larry Masters" email="phpnut@cakephp.org" />
  85. <license>MIT License</license>
  86. <version release="${pear.version}" api="${pear.version}" />
  87. <stability release="${pear.stability}" api="${pear.stability}" />
  88. <notes>http://github.com/cakephp/cakephp/blob/master/README</notes>
  89. <dependencies>
  90. <php minimum_version="5.2.9" />
  91. <pear minimum_version="1.9.0" recommended_version="1.9.4" />
  92. <package name="PHPUnit" channel="pear.phpunit.de" minimum_version="3.5.0" type="optional" />
  93. </dependencies>
  94. <dirroles key="bin">script</dirroles>
  95. <release>
  96. <install as="cake" name="bin/cake" />
  97. <install as="cake.php" name="bin/cake.php" />
  98. <install as="cake.bat" name="bin/cake.bat" />
  99. </release>
  100. </d51pearpkg2>
  101. </target>
  102. <!-- Generate the PEAR package from a directory and move the files to the dist folder -->
  103. <target name="generate-package" depends="define-pear-package">
  104. <exec command="pear package" dir="${build.dir}/${project.name}-${version}" passthru="true"/>
  105. <echo msg="Moving ${project.name}-${pear.version}.tgz"/>
  106. <move file="${build.dir}/${project.name}-${version}/${project.name}-${pear.version}.tgz" todir="${dist.dir}" />
  107. </target>
  108. <!--
  109. Bump the version number and commit that.
  110. -->
  111. <target name="next-version" depends="prepare">
  112. <echo msg="Incrementing version." />
  113. <propertyprompt propertyName="release_version" defaultValue="${version}" promptText="Enter version to be released (without -DEV)"/>
  114. <echo msg="$file = file_get_contents('./lib/Cake/VERSION.txt'); $file = str_replace('${version}', '${release_version}', $file); file_put_contents('./lib/Cake/VERSION.txt', $file);" />
  115. <exec executable="php">
  116. <arg value="-r" />
  117. <arg value="$file = file_get_contents('./lib/Cake/VERSION.txt'); $file = str_replace('${version}', '${release_version}', $file); file_put_contents('./lib/Cake/VERSION.txt', $file);" />
  118. </exec>
  119. <echo msg="Version number updated." />
  120. </target>
  121. <!--
  122. Create the release commit that updates the version number and pushes the commits.
  123. -->
  124. <target name="release-commit" depends="prepare,next-version">
  125. <echo msg="Creating new release commit" />
  126. <exec command="git add ./lib/Cake/VERSION.txt" />
  127. <exec command="git commit -m 'Update version number to ${release_version}'" />
  128. <exec command="git tag -a ${release_version} -m 'CakePHP ${release_version}'" />
  129. <propertyprompt propertyName="shipit" defaultValue="n" promptText="Ship the new commit and tag?" />
  130. <condition property="noshipit" value="1">
  131. <not>
  132. <equals arg1="y" arg2="${shipit}" casesensitive="false" />
  133. </not>
  134. </condition>
  135. <fail if="noshipit" msg="You said not to ship it." />
  136. <exec command="git push ${git.remote}" />
  137. <exec command="git push --tags ${git.remote}" />
  138. <echo msg="Pushed commit and tag." />
  139. </target>
  140. <!--
  141. Upload to pirium pear channel.
  142. -->
  143. <target name="distribute">
  144. </target>
  145. <!--
  146. Top level easy to type targets
  147. -->
  148. <target name="build" depends="generate-package" />
  149. <target name="release" depends="release-commit,build,distribute" />
  150. </project>