pictcode / build.xml @ 16e57cae
履歴 | 表示 | アノテート | ダウンロード (9.979 KB)
| 1 | 635eef61 | spyder1211 | <?xml version="1.0" encoding="utf-8"?>
 | 
|---|---|---|---|
| 2 | <project name="CakePHP" default="build"> | ||
| 3 |         <!--
 | ||
| 4 |         Build.xml file for CakePHP
 | ||
| 5 | |||
| 6 |         Uses phing to create releases, and pear packages.
 | ||
| 7 |         Based off of build.xml in doctrine.
 | ||
| 8 | |||
| 9 |         Requires the cakephp/d51PearPkg2 to be installed:
 | ||
| 10 | |||
| 11 |         pear channel-discover pear.domain51.com
 | ||
| 12 |         pear install cakephp/Phing_d51PearPkg2Task
 | ||
| 13 | |||
| 14 |         Use the `release` task to update VERSION.txt, and create a new tag.
 | ||
| 15 |         Use the `build` task to create a pear package based on the current working copy.
 | ||
| 16 |         Use the `clean` task to clean up packaging artifacts.
 | ||
| 17 | |||
| 18 |         -->
 | ||
| 19 | |||
| 20 | <taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" /> | ||
| 21 | <property file="build.properties" /> | ||
| 22 | |||
| 23 |         <!--
 | ||
| 24 |                 The set of files we're going to package
 | ||
| 25 |                 Exclude the cli scripts, as they get installed separately.
 | ||
| 26 |          -->
 | ||
| 27 | <fileset id="libs" dir="./lib/Cake"> | ||
| 28 | <include name="**" /> | ||
| 29 | <exclude name="Console/cake.bat" /> | ||
| 30 | <exclude name="Console/cake.php" /> | ||
| 31 | <exclude name="Console/cake" /> | ||
| 32 | <exclude name="Test/bake_compare/**" /> | ||
| 33 | <exclude name="Test/Case/**" /> | ||
| 34 | <exclude name="Test/test_app/**" /> | ||
| 35 |         </fileset>
 | ||
| 36 | |||
| 37 |         <!--
 | ||
| 38 |                 CLI scripts to package and install
 | ||
| 39 |         -->
 | ||
| 40 | <fileset id="cli" dir="./lib/Cake/Console"> | ||
| 41 | <include name="cake.bat" /> | ||
| 42 | <include name="cake.php" /> | ||
| 43 | <include name="cake" /> | ||
| 44 |         </fileset>
 | ||
| 45 | |||
| 46 |         <!-- start fresh each time.  Remove the dist and build dirs -->
 | ||
| 47 | <target name="clean"> | ||
| 48 | <delete dir="${build.dir}" includeemptydirs="true" /> | ||
| 49 | <delete dir="${dist.dir}" includeemptydirs="true" /> | ||
| 50 |         </target>
 | ||
| 51 | |||
| 52 |         <!-- Read the current version, so we can replace it -->
 | ||
| 53 | <target name="current-version"> | ||
| 54 | <exec executable="php" outputProperty="version"> | ||
| 55 | <arg value="-r" /> | ||
| 56 | <arg value="$fh = file('./lib/Cake/VERSION.txt'); echo array_pop($fh);" /> | ||
| 57 |                 </exec>
 | ||
| 58 |         </target>
 | ||
| 59 | |||
| 60 |         <!-- Makes directories and sets properties -->
 | ||
| 61 | <target name="prepare" depends="current-version"> | ||
| 62 |                 <!-- set PEAR stability based on version number. -->
 | ||
| 63 | <condition property="pear.stability" value="beta"> | ||
| 64 | <contains string="${version}" substring="beta" casesensitive="false"/> | ||
| 65 |                 </condition>
 | ||
| 66 | <condition property="pear.stability" value="alpha"> | ||
| 67 | <contains string="${version}" substring="alpha" casesensitive="false"/> | ||
| 68 |                 </condition>
 | ||
| 69 | <condition property="pear.stability" value="devel"> | ||
| 70 | <contains string="${version}" substring="dev" casesensitive="false"/> | ||
| 71 |                 </condition>
 | ||
| 72 | <condition property="pear.stability" value="beta"> | ||
| 73 | <contains string="${version}" substring="rc" casesensitive="false" /> | ||
| 74 |                 </condition>
 | ||
| 75 | <condition property="pear.stability" value="stable"> | ||
| 76 | <not><isset property="pear.stability"/></not> | ||
| 77 |                 </condition>
 | ||
| 78 | |||
| 79 |                 <!-- pear versions need to not have '-' -->
 | ||
| 80 | <exec executable="php" outputProperty="pear.version"> | ||
| 81 | <arg value="-r" /> | ||
| 82 | <arg value="echo str_replace(array('-'), array(''), '${version}');" /> | ||
| 83 |                 </exec>
 | ||
| 84 | |||
| 85 |                 <!-- Used for other targets -->
 | ||
| 86 | <property name="pear.package" value="${project.name}-${pear.version}" /> | ||
| 87 | |||
| 88 | <echo msg="Preparing package of ${version} (${pear.version}+${pear.stability})" /> | ||
| 89 | |||
| 90 |                 <!-- Get the current git branch -->
 | ||
| 91 | <exec command="git name-rev HEAD 2>/dev/null | awk '{ print $2 }'" outputProperty="git.branch" /> | ||
| 92 |         </target>
 | ||
| 93 | |||
| 94 |         <!--
 | ||
| 95 |                 Copy all the files to build/ so they can be packaged up.
 | ||
| 96 |         -->
 | ||
| 97 | <target name="copy-files" depends="clean,prepare"> | ||
| 98 | <echo msg="Creating build + dist directories." /> | ||
| 99 | <mkdir dir="${build.dir}" /> | ||
| 100 | <mkdir dir="${dist.dir}" /> | ||
| 101 | |||
| 102 | <echo msg="Copying files to build directory" /> | ||
| 103 | <copy todir="${build.dir}/${pear.package}/Cake"> | ||
| 104 | <fileset refid="libs" /> | ||
| 105 |                 </copy>
 | ||
| 106 | <copy todir="${build.dir}/${pear.package}/bin"> | ||
| 107 | <fileset refid="cli" /> | ||
| 108 |                 </copy>
 | ||
| 109 |         </target>
 | ||
| 110 | |||
| 111 |         <!--
 | ||
| 112 |                 Define the package.xml.  Using xml to make xml is fun!
 | ||
| 113 |         -->
 | ||
| 114 | <target name="define-pear-package" depends="copy-files"> | ||
| 115 | <d51pearpkg2 addhiddenfiles="true" baseinstalldir="/" dir="${build.dir}/${pear.package}"> | ||
| 116 | <name>CakePHP</name> | ||
| 117 | <summary>CakePHP Rapid Development Framework</summary> | ||
| 118 | <channel>pear.cakephp.org</channel> | ||
| 119 | <description>CakePHP is an application development framework for PHP 5.2+</description> | ||
| 120 | |||
| 121 | <lead user="mark_story" name="Mark Story" email="mark@mark-story.com" /> | ||
| 122 | <lead user="lorenzo" name="José Lorenzo Rodríguez" email="jose.zap@gmail.com" /> | ||
| 123 | <lead user="PhpNut" name="Larry Masters" email="phpnut@cakephp.org" /> | ||
| 124 | <developer user="ADmad" name="Adnan Sarela" email="admad.coder@gmail.com" /> | ||
| 125 | <developer user="AD7six" name="Andy Dawson" email="andydawson76@gmail.com" /> | ||
| 126 | <developer user="Ceeram" name="Marc Ypes" email="c33ram@gmail.com" /> | ||
| 127 | <developer user="jrbasso" name="Juan Basso" email="" /> | ||
| 128 | <developer user="Predominant" name="Graham Weldon" email="graham@grahamweldon.com" /> | ||
| 129 | <developer user="renan.saddam" name="Renan Gonçalves" email="renan.saddam@gmail.com" /> | ||
| 130 | <developer user="rchavik" name="Rachman Chavik" email="rchavik@xintesa.com" /> | ||
| 131 | |||
| 132 | <license>MIT License</license> | ||
| 133 | <version release="${pear.version}" api="${pear.version}" /> | ||
| 134 | <stability release="${pear.stability}" api="${pear.stability}" /> | ||
| 135 | <notes>https://github.com/cakephp/cakephp/blob/master/README</notes> | ||
| 136 |                         <dependencies>
 | ||
| 137 | <php minimum_version="5.2.8" /> | ||
| 138 | <pear minimum_version="1.9.0" recommended_version="1.9.4" /> | ||
| 139 |                         </dependencies>
 | ||
| 140 | <dirroles key="bin">script</dirroles> | ||
| 141 | <dirroles key="Cake/Console/Templates/skel">php</dirroles> | ||
| 142 | <dirroles key="Cake/Console/Templates/default">php</dirroles> | ||
| 143 | <dirroles key="Cake/View">php</dirroles> | ||
| 144 |                         <release>
 | ||
| 145 | <install as="cake.bat" name="bin/cake.bat" /> | ||
| 146 | <install as="cake.php" name="bin/cake.php" /> | ||
| 147 | <install as="cake" name="bin/cake" /> | ||
| 148 |                         </release>
 | ||
| 149 | <exceptions key="Cake/VERSION.txt">php</exceptions> | ||
| 150 | <exceptions key="Cake/LICENSE.txt">php</exceptions> | ||
| 151 | <exceptions key="Cake/Config/cacert.pem">php</exceptions> | ||
| 152 | <exceptions key="Cake/Console/Templates/skel/.htaccess">php</exceptions> | ||
| 153 | <exceptions key="Cake/Console/Templates/skel/webroot/.htaccess">php</exceptions> | ||
| 154 |                 </d51pearpkg2>
 | ||
| 155 |         </target>
 | ||
| 156 | |||
| 157 |         <!-- Generate the PEAR package from a directory and move the files to the dist folder -->
 | ||
| 158 | <target name="generate-package" depends="define-pear-package"> | ||
| 159 | <exec command="pear package" dir="${build.dir}/${pear.package}" passthru="true"/> | ||
| 160 | <echo msg="Moving ${pear.package}.tgz"/> | ||
| 161 | <move file="${build.dir}/${pear.package}/${pear.package}.tgz" todir="${dist.dir}" /> | ||
| 162 |         </target>
 | ||
| 163 | |||
| 164 |         <!--
 | ||
| 165 |                 Updates the local copy to the latest head.
 | ||
| 166 |         -->
 | ||
| 167 | <target name="update-branch"> | ||
| 168 | <echo msg="Updating to latest master." /> | ||
| 169 | <exec executable="git pull"> | ||
| 170 | <arg value="${git.remote}" /> | ||
| 171 | <arg value="master" /> | ||
| 172 |                 </exec>
 | ||
| 173 |         </target>
 | ||
| 174 | |||
| 175 |         <!--
 | ||
| 176 |                 Bump the version number and commit that.
 | ||
| 177 |         -->
 | ||
| 178 | <target name="next-version" depends="current-version"> | ||
| 179 | <echo msg="Incrementing version." /> | ||
| 180 | <propertyprompt propertyName="release_version" defaultValue="${version}" promptText="Enter version to be released."/> | ||
| 181 | <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);" /> | ||
| 182 | <exec executable="php"> | ||
| 183 | <arg value="-r" /> | ||
| 184 | <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);" /> | ||
| 185 |                 </exec>
 | ||
| 186 | <echo msg="Version number updated." /> | ||
| 187 | <property name="version" value="${release_version}" override="true" /> | ||
| 188 |         </target>
 | ||
| 189 | |||
| 190 |         <!--
 | ||
| 191 |                 Create the release commit that updates the version number and pushes the commits.
 | ||
| 192 |         -->
 | ||
| 193 | <target name="release-commit" depends="update-branch,next-version,prepare"> | ||
| 194 | <echo msg="Creating new release commit" /> | ||
| 195 | <exec command="git add ./lib/Cake/VERSION.txt" logoutput="true" checkreturn="true" /> | ||
| 196 | <exec command="git commit -m 'Update version number to ${release_version}'" logoutput="true" checkreturn="true" /> | ||
| 197 | <exec command="git tag -s ${release_version} -m 'CakePHP ${release_version}'" logoutput="true" checkreturn="true" /> | ||
| 198 | |||
| 199 | <propertyprompt propertyName="shipit" defaultValue="n" promptText="Ship the new commit and tag?" /> | ||
| 200 | <condition property="noshipit" value="1"> | ||
| 201 | <equals arg1="n" arg2="${shipit}" casesensitive="false" /> | ||
| 202 |                 </condition>
 | ||
| 203 | <fail if="noshipit" msg="You said not to ship it." /> | ||
| 204 | |||
| 205 | <echo msg="Pushing commit and tag." /> | ||
| 206 | <exec command="git push ${git.remote} ${git.branch}" logoutput="true" checkreturn="true" /> | ||
| 207 | <exec command="git push ${git.remote} ${release_version}" logoutput="true" checkreturn="true" /> | ||
| 208 | <echo msg="Push complete." /> | ||
| 209 |         </target>
 | ||
| 210 | |||
| 211 |         <!--
 | ||
| 212 |                 Upload to pirum pear channel.
 | ||
| 213 |         -->
 | ||
| 214 | <target name="distribute" depends="prepare" description="Upload pear packages to pear.cakephp.org"> | ||
| 215 | <echo msg="Uploading tgz file to cakephp.org" /> | ||
| 216 | <exec command="scp ${dist.dir}/${pear.package}.tgz cakephp@cakephp.org:${pirum.dir}" dir="." checkreturn="true" /> | ||
| 217 | |||
| 218 | <echo msg="Adding new release to pirum" /> | ||
| 219 | <exec command="ssh cakephp@cakephp.org pirum add ${pirum.dir} ${pirum.dir}/${pear.package}.tgz" checkreturn="true" /> | ||
| 220 |         </target>
 | ||
| 221 | |||
| 222 | <target name="codestyle" description="Check codestyle (human readable format)"> | ||
| 223 |                 <phpcodesniffer
 | ||
| 224 | standard="CakePHP" | ||
| 225 | allowedFileExtensions="php"> | ||
| 226 | <fileset refid="libs" /> | ||
| 227 |                 </phpcodesniffer>
 | ||
| 228 |         </target>
 | ||
| 229 | |||
| 230 | <target name="reports-ci"> | ||
| 231 |                 <phpcodesniffer
 | ||
| 232 | standard="CakePHP" | ||
| 233 | allowedFileExtensions="php"> | ||
| 234 | <fileset refid="libs" /> | ||
| 235 | <formatter type="checkstyle" outfile="checkstyle.xml" /> | ||
| 236 |                 </phpcodesniffer>
 | ||
| 237 |                 <phpcpd
 | ||
| 238 | minLines="4" | ||
| 239 | minTokens="50"> | ||
| 240 | <fileset refid="libs" /> | ||
| 241 | <formatter type="pmd" outfile="pmd-cpd.xml"/> | ||
| 242 |                 </phpcpd>
 | ||
| 243 |                 <phpdepend>
 | ||
| 244 | <fileset refid="libs" /> | ||
| 245 | <logger type="jdepend-xml" outfile="jdepend.xml"/> | ||
| 246 |                 </phpdepend>
 | ||
| 247 | <phpmd rulesets="codesize,unusedcode,design"> | ||
| 248 | <fileset refid="libs" /> | ||
| 249 | <formatter type="xml" outfile="reports/pmd.html"/> | ||
| 250 |                 </phpmd>
 | ||
| 251 |         </target>
 | ||
| 252 | |||
| 253 |         <!--
 | ||
| 254 |                 Top level easy to type targets
 | ||
| 255 |         -->
 | ||
| 256 | <target name="build" depends="generate-package" description="Generate a pear package" /> | ||
| 257 | <target name="release" depends="release-commit,build,distribute" description="Release a new version of CakePHP" /> | ||
| 258 | <target name="code-reports" depends="reports-ci" | ||
| 259 | description="Run the code reports, generating XML output for CI server use." /> | ||
| 260 | |||
| 261 | </project> |