Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 6d1dd5f4eb
Fetching contributors…

Cannot retrieve contributors at this time

209 lines (178 sloc) 8.322 kb
<?xml version="1.0" encoding="utf-8"?>
<project name="CakePHP" default="build">
Build.xml file for CakePHP
Uses phing to create releases, and pear packages.
Based off of build.xml in doctrine.
Requires the d51PearPkg2 to be installed:
pear channel-discover
pear install domain51/Phing_d51PearPkg2Task
Use the `release` task to update VERSION.txt, and create a new tag.
Use the `build` task to create a pear package based on the current working copy.
Use the `clean` task to clean up packaging artifacts.
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
<property file="" />
The set of files we're going to package
Exclude the cli scripts, as they get installed separately.
<fileset id="libs" dir="./lib/Cake">
<include name="**" />
<exclude name="Console/cake.bat" />
<exclude name="Console/cake.php" />
<exclude name="Console/cake" />
CLI scripts to package and install
<fileset id="cli" dir="./lib/Cake/Console">
<include name="cake.bat" />
<include name="cake.php" />
<include name="cake" />
<!-- start fresh each time. Remove the dist and build dirs -->
<target name="clean">
<delete dir="${build.dir}" includeemptydirs="true" />
<delete dir="${dist.dir}" includeemptydirs="true" />
<!-- Read the current version, so we can replace it -->
<target name="current-version">
<exec executable="php" outputProperty="version">
<arg value="-r" />
<arg value="$fh = file('./lib/Cake/VERSION.txt'); echo array_pop($fh);" />
<!-- Makes directories and sets properties -->
<target name="prepare" depends="current-version">
<!-- set PEAR stability based on version number. -->
<condition property="pear.stability" value="beta">
<contains string="${version}" substring="beta" casesensitive="false"/>
<condition property="pear.stability" value="alpha">
<contains string="${version}" substring="alpha" casesensitive="false"/>
<condition property="pear.stability" value="devel">
<contains string="${version}" substring="dev" casesensitive="false"/>
<condition property="pear.stability" value="beta">
<contains string="${version}" substring="rc" casesensitive="false" />
<condition property="pear.stability" value="stable">
<not><isset property="pear.stability"/></not>
<!-- pear versions need to not have '-' -->
<exec executable="php" outputProperty="pear.version">
<arg value="-r" />
<arg value="echo str_replace(array('-'), array(''), '${version}');" />
<!-- Used for other targets -->
<property name="pear.package" value="${}-${pear.version}" />
<echo msg="Preparing package of ${version} (${pear.version}+${pear.stability})" />
<!-- Get the current git branch -->
<exec command="git name-rev HEAD 2>/dev/null | awk '{ print $2 }'" outputProperty="git.branch" />
Copy all the files to build/ so they can be packaged up.
<target name="copy-files" depends="clean,prepare">
<echo msg="Creating build + dist directories." />
<mkdir dir="${build.dir}" />
<mkdir dir="${dist.dir}" />
<echo msg="Copying files to build directory" />
<copy todir="${build.dir}/${pear.package}/Cake">
<fileset refid="libs" />
<copy todir="${build.dir}/${pear.package}/bin">
<fileset refid="cli" />
Define the package.xml. Using xml to make xml is fun!
<target name="define-pear-package" depends="copy-files">
<d51pearpkg2 baseinstalldir="/" dir="${build.dir}/${pear.package}">
<summary>CakePHP Rapid Development Framework</summary>
<description>CakePHP is an application development framework for PHP 5.2+</description>
<lead user="mark_story" name="Mark Story" email="" />
<lead user="lorenzo" name="José Lorenzo Rodríguez" email="" />
<lead user="PhpNut" name="Larry Masters" email="" />
<developer user="ADmad" name="Adnan Sarela" email="" />
<developer user="AD7six" name="Andy Dawson" email="" />
<developer user="Ceeram" name="Marc Ypes" email="" />
<developer user="jrbasso" name="Juan Basso" email="" />
<developer user="Predominant" name="Graham Weldon" email="" />
<developer user="renan.saddam" name="Renan Gonçalves" email="" />
<developer user="rchavik" name="Rachman Chavik" email="" />
<license>MIT License</license>
<version release="${pear.version}" api="${pear.version}" />
<stability release="${pear.stability}" api="${pear.stability}" />
<php minimum_version="5.2.8" />
<pear minimum_version="1.9.0" recommended_version="1.9.4" />
<package name="PHPUnit" channel="" minimum_version="3.5.0" type="optional" />
<dirroles key="bin">script</dirroles>
<install as="cake" name="bin/cake" />
<install as="cake.php" name="bin/cake.php" />
<install as="cake.bat" name="bin/cake.bat" />
<!-- Generate the PEAR package from a directory and move the files to the dist folder -->
<target name="generate-package" depends="define-pear-package">
<exec command="pear package" dir="${build.dir}/${pear.package}" passthru="true"/>
<echo msg="Moving ${pear.package}.tgz"/>
<move file="${build.dir}/${pear.package}/${pear.package}.tgz" todir="${dist.dir}" />
Bump the version number and commit that.
<target name="next-version" depends="current-version">
<echo msg="Incrementing version." />
<propertyprompt propertyName="release_version" defaultValue="${version}" promptText="Enter version to be released."/>
<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);" />
<exec executable="php">
<arg value="-r" />
<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);" />
<echo msg="Version number updated." />
<property name="version" value="${release_version}" override="true" />
Create the release commit that updates the version number and pushes the commits.
<target name="release-commit" depends="next-version,prepare">
<echo msg="Creating new release commit" />
<exec command="git add ./lib/Cake/VERSION.txt" logoutput="true" checkreturn="true" />
<exec command="git commit -m 'Update version number to ${release_version}'" logoutput="true" checkreturn="true" />
<exec command="git tag -a ${release_version} -m 'CakePHP ${release_version}'" logoutput="true" checkreturn="true" />
<propertyprompt propertyName="shipit" defaultValue="n" promptText="Ship the new commit and tag?" />
<condition property="noshipit" value="1">
<equals arg1="n" arg2="${shipit}" casesensitive="false" />
<fail if="noshipit" msg="You said not to ship it." />
<echo msg="Pushing commit and tag." />
<exec command="git push ${git.remote} ${git.branch}" logoutput="true" checkreturn="true" />
<exec command="git push ${git.remote} ${release_version}" logoutput="true" checkreturn="true" />
<echo msg="Push complete." />
Upload to pirum pear channel.
<target name="distribute" depends="prepare">
<echo msg="Uploading tgz file to" />
<exec command="scp ${dist.dir}/${pear.package}.tgz${pirum.dir}" dir="." checkreturn="true" />
<echo msg="Adding new release to pirum" />
<exec command="ssh pirum add ${pirum.dir} ${pirum.dir}/${pear.package}.tgz" checkreturn="true" />
Top level easy to type targets
<target name="build" depends="generate-package" />
<target name="release" depends="release-commit,build,distribute" />
Jump to Line
Something went wrong with that request. Please try again.