2 <project name="kohana" default="help">
3 <property environment="env"/>
5 <property name="basedir" value="${project.basedir}"/>
6 <property name="builddir" value="${basedir}/build"/>
8 <property name="branch" value="3.0/develop"/>
10 <property name="submodules" value="system,modules/auth,modules/cache,modules/codebench,modules/database,modules/image,modules/oauth,modules/orm,modules/pagination,modules/unittest,modules/userguide"/>
12 <!-- Shows the help message -->
14 <echo message="General Targets"/>
15 <echo message="==============="/>
16 <echo message="phing test Run unit tests."/>
17 <echo message="phing test-log Run unit tests with logging enabled."/>
18 <echo message="phing phpcs Run phpcs."/>
19 <echo message="phing phpcs-log Run phpcs with logging enabled."/>
20 <echo message="phing phpmd Run phpmd."/>
21 <echo message="phing phpmd-log Run phpmd with logging enabled."/>
22 <echo message="phing phpcpd-log Run phpcpd with logging enabled."/>
23 <echo message="phing pdepend-log Run pdepend with logging enabled."/>
24 <echo message="phing phpcb-log Run phpcb with logging enabled."/>
26 <echo message="Kohana Developer Targets"/>
27 <echo message="========================"/>
28 <echo message="phing dev-setup Setup for development on Kohana itself."/>
29 <echo message="phing git-status Show the git status of each submodule."/>
30 <echo message="phing git-checkout Checkout a branch accross all submodules."/>
31 <echo message="phing git-pull Perform a pull for each submodule."/>
32 <echo message="phing git-push Perform a push for each submodule."/>
34 <echo message="Misc Targets"/>
35 <echo message="============"/>
36 <echo message="phing ci Alias task for continuous integration servers"/>
41 <delete dir="${builddir}"/>
42 <!-- Create build directories -->
43 <mkdir dir="${builddir}/coverage"/>
44 <mkdir dir="${builddir}/logs"/>
45 <mkdir dir="${builddir}/release"/>
46 <mkdir dir="${builddir}/code-browser"/>
49 <target name="dev-setup">
50 <property name="git-checkout-branch" value="${branch}"/> <!-- Prevents git-checkout asking for a branch name -->
51 <exec command="git submodule update --init --recursive" dir="${basedir}" />
52 <phingcall target="_dev-setup-remotes" />
53 <phingcall target="git-pull" />
54 <phingcall target="git-checkout" />
57 <target name="git-pull">
58 <phingcall target="_git-pull">
59 <property name="dir" value="." />
61 <foreach list="${submodules}" param="dir" target="_git-pull"/>
64 <target name="_git-pull">
65 <exec command="git pull dev" dir="${dir}"/>
68 <target name="git-checkout">
71 <isset property="git-checkout-branch"/>
74 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
78 <phingcall target="_git-checkout">
79 <property name="dir" value="." />
82 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
85 <target name="_git-checkout">
86 <exec returnProperty="git-checkout-branch-exists" command="git show-ref --quiet --verify -- 'refs/remotes/dev/${git-checkout-branch}'" dir="${dir}" passthru="true"/>
88 <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
90 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
93 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
98 <target name="git-push">
99 <foreach list="${submodules}" param="dir" target="_git-push"/>
100 <phingcall target="_git-push">
101 <property name="dir" value="." />
105 <target name="_git-push">
106 <exec command="git push dev" dir="${dir}" passthru="true"/>
109 <target name="git-status">
110 <foreach list="${submodules}" param="dir" target="_git-status"/>
111 <phingcall target="_git-status">
112 <property name="dir" value="." />
116 <target name="_git-status">
117 <exec command="git status" dir="${dir}" passthru="true"/>
120 <target name="_dev-setup-remotes">
121 <!-- TODO: Clean up... -->
122 <phingcall target="_dev-setup-remote">
123 <property name="repository" value="git@github.com:kohana/kohana.git" />
124 <property name="dir" value="${basedir}" />
126 <phingcall target="_dev-setup-remote">
127 <property name="repository" value="git@github.com:kohana/core.git" />
128 <property name="dir" value="${basedir}/system" />
130 <phingcall target="_dev-setup-remote">
131 <property name="repository" value="git@github.com:kohana/auth.git" />
132 <property name="dir" value="${basedir}/modules/auth" />
134 <phingcall target="_dev-setup-remote">
135 <property name="repository" value="git@github.com:kohana/cache.git" />
136 <property name="dir" value="${basedir}/modules/cache" />
138 <phingcall target="_dev-setup-remote">
139 <property name="repository" value="git@github.com:kohana/codebench.git" />
140 <property name="dir" value="${basedir}/modules/codebench" />
142 <phingcall target="_dev-setup-remote">
143 <property name="repository" value="git@github.com:kohana/database.git" />
144 <property name="dir" value="${basedir}/modules/database" />
146 <phingcall target="_dev-setup-remote">
147 <property name="repository" value="git@github.com:kohana/image.git" />
148 <property name="dir" value="${basedir}/modules/image" />
150 <phingcall target="_dev-setup-remote">
151 <property name="repository" value="git@github.com:kohana/oauth.git" />
152 <property name="dir" value="${basedir}/modules/oauth" />
154 <phingcall target="_dev-setup-remote">
155 <property name="repository" value="git@github.com:kohana/orm.git" />
156 <property name="dir" value="${basedir}/modules/orm" />
158 <phingcall target="_dev-setup-remote">
159 <property name="repository" value="git@github.com:kohana/pagination.git" />
160 <property name="dir" value="${basedir}/modules/pagination" />
162 <phingcall target="_dev-setup-remote">
163 <property name="repository" value="git@github.com:kohana/unittest.git" />
164 <property name="dir" value="${basedir}/modules/unittest" />
166 <phingcall target="_dev-setup-remote">
167 <property name="repository" value="git@github.com:kohana/userguide.git" />
168 <property name="dir" value="${basedir}/modules/userguide" />
172 <target name="_dev-setup-remote">
173 <exec command="git remote rm dev" dir="${dir}"/>
174 <exec command="git remote add dev ${repository}" dir="${dir}"/>
177 <!-- Run unit tests -->
179 <exec command="phpunit --bootstrap=application/test_bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
182 <!-- Run unit tests and generate junit.xml and clover.xml -->
183 <target name="test-log">
184 <exec command="phpunit --bootstrap=application/test_bootstrap.php --coverage-html=${builddir}/coverage --log-junit=${builddir}/logs/junit.xml --coverage-clover=${builddir}/logs/clover.xml modules/unittest/tests.php" checkreturn="true" passthru="true"/>
187 <!-- Run PHP Code Sniffer -->
188 <target name="phpcs">
189 <exec command="phpcs --standard=Kohana --ignore=*.js,*.css,**/vendor/**,**/tests/** ${basedir}" passthru="true"/>
192 <!-- Run PHP Code Sniffer and generate checkstyle.xml -->
193 <target name="phpcs-log">
194 <exec command="phpcs --standard=Kohana --ignore=*.js,*.css,**/vendor/**,**/tests/** --report=checkstyle --report-file=${builddir}/logs/checkstyle.xml ${basedir}" passthru="false"/>
197 <!-- Run PHP Mess Detector -->
198 <target name="phpmd">
199 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**" passthru="true"/>
202 <!-- Run PHP Mess Detector and generate pmd.xml -->
203 <target name="phpmd-log">
204 <exec command="phpmd ${basedir} xml codesize,unusedcode --exclude=**/vendor/** --reportfile ${builddir}/logs/pmd.xml" passthru="true"/>
207 <!-- Run PHP Copy/Paste Detector and generate pmd.xml -->
208 <target name="phpcpd-log">
209 <exec command="phpcpd --log-pmd ${builddir}/logs/pmd-cpd.xml ${basedir}" passthru="true"/>
212 <!-- Run PHP Depend and generate jdepend.xml -->
213 <target name="pdepend-log">
214 <exec command="pdepend --jdepend-xml=${builddir}/logs/jdepend.xml ${basedir}" passthru="true"/>
217 <!-- Run PHP CodeBrowser and generate output -->
218 <target name="phpcb-log">
219 <exec command="phpcb --log ${builddir}/logs --source ${basedir} --output ${builddir}/code-browser" passthru="true"/>
222 <!-- Build a release .zip -->
224 <!-- Pick an appropriate dist filename -->
226 <isset property="dist.filename" />
230 <!-- basically - are we running inside hudson? -->
231 <isset property="env.BUILD_NUMBER" />
232 <isset property="env.JOB_NAME" />
235 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
238 <property name="dist.filename" value="kohana" />
244 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
245 <fileset dir="${basedir}">
246 <include name="**/**"/>
248 <exclude name="*.zip" />
249 <exclude name="build/**" />
251 <exclude name="build.xml" />
252 <exclude name="phpunit.xml" />
254 <exclude name="**/.git/**" />
255 <exclude name="**/.git*" />
260 <!-- Hudson CI target -->
261 <target name="ci" depends="clean">
262 <phingcall target="test-log"/>
263 <phingcall target="pdepend-log"/>
264 <phingcall target="phpmd-log"/>
265 <phingcall target="phpcpd-log"/>
266 <phingcall target="phpcs-log"/>
267 <phingcall target="phpcb-log"/>