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"/>
37 <echo message="phing dist Build a release .zip"/>
42 <delete dir="${builddir}"/>
43 <!-- Create build directories -->
44 <mkdir dir="${builddir}/coverage"/>
45 <mkdir dir="${builddir}/logs"/>
46 <mkdir dir="${builddir}/release"/>
47 <mkdir dir="${builddir}/code-browser"/>
50 <target name="dev-setup">
51 <property name="git-checkout-branch" value="${branch}"/> <!-- Prevents git-checkout asking for a branch name -->
52 <exec command="git submodule update --init --recursive" dir="${basedir}" />
53 <phingcall target="_dev-setup-remotes" />
54 <phingcall target="git-pull" />
55 <phingcall target="git-checkout" />
58 <target name="git-pull">
59 <phingcall target="_git-pull">
60 <property name="dir" value="." />
62 <foreach list="${submodules}" param="dir" target="_git-pull"/>
65 <target name="_git-pull">
66 <exec command="git pull dev" dir="${dir}"/>
69 <target name="git-checkout">
72 <isset property="git-checkout-branch"/>
75 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
79 <phingcall target="_git-checkout">
80 <property name="dir" value="." />
83 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
86 <target name="_git-checkout">
87 <exec returnProperty="git-checkout-branch-exists" command="git show-ref --quiet --verify -- 'refs/remotes/dev/${git-checkout-branch}'" dir="${dir}" passthru="true"/>
89 <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
91 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
94 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
99 <target name="git-push">
100 <foreach list="${submodules}" param="dir" target="_git-push"/>
101 <phingcall target="_git-push">
102 <property name="dir" value="." />
106 <target name="_git-push">
107 <exec command="git push dev" dir="${dir}" passthru="true"/>
110 <target name="git-status">
111 <foreach list="${submodules}" param="dir" target="_git-status"/>
112 <phingcall target="_git-status">
113 <property name="dir" value="." />
117 <target name="_git-status">
118 <exec command="git status" dir="${dir}" passthru="true"/>
121 <target name="_dev-setup-remotes">
122 <!-- TODO: Clean up... -->
123 <phingcall target="_dev-setup-remote">
124 <property name="repository" value="git@github.com:kohana/kohana.git" />
125 <property name="dir" value="${basedir}" />
127 <phingcall target="_dev-setup-remote">
128 <property name="repository" value="git@github.com:kohana/core.git" />
129 <property name="dir" value="${basedir}/system" />
131 <phingcall target="_dev-setup-remote">
132 <property name="repository" value="git@github.com:kohana/auth.git" />
133 <property name="dir" value="${basedir}/modules/auth" />
135 <phingcall target="_dev-setup-remote">
136 <property name="repository" value="git@github.com:kohana/cache.git" />
137 <property name="dir" value="${basedir}/modules/cache" />
139 <phingcall target="_dev-setup-remote">
140 <property name="repository" value="git@github.com:kohana/codebench.git" />
141 <property name="dir" value="${basedir}/modules/codebench" />
143 <phingcall target="_dev-setup-remote">
144 <property name="repository" value="git@github.com:kohana/database.git" />
145 <property name="dir" value="${basedir}/modules/database" />
147 <phingcall target="_dev-setup-remote">
148 <property name="repository" value="git@github.com:kohana/image.git" />
149 <property name="dir" value="${basedir}/modules/image" />
151 <phingcall target="_dev-setup-remote">
152 <property name="repository" value="git@github.com:kohana/oauth.git" />
153 <property name="dir" value="${basedir}/modules/oauth" />
155 <phingcall target="_dev-setup-remote">
156 <property name="repository" value="git@github.com:kohana/orm.git" />
157 <property name="dir" value="${basedir}/modules/orm" />
159 <phingcall target="_dev-setup-remote">
160 <property name="repository" value="git@github.com:kohana/pagination.git" />
161 <property name="dir" value="${basedir}/modules/pagination" />
163 <phingcall target="_dev-setup-remote">
164 <property name="repository" value="git@github.com:kohana/unittest.git" />
165 <property name="dir" value="${basedir}/modules/unittest" />
167 <phingcall target="_dev-setup-remote">
168 <property name="repository" value="git@github.com:kohana/userguide.git" />
169 <property name="dir" value="${basedir}/modules/userguide" />
173 <target name="_dev-setup-remote">
174 <exec command="git remote rm dev" dir="${dir}"/>
175 <exec command="git remote add dev ${repository}" dir="${dir}"/>
178 <!-- Run unit tests -->
180 <exec command="phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
183 <!-- Run unit tests and generate junit.xml and clover.xml -->
184 <target name="test-log">
185 <exec command="phpunit --bootstrap=modules/unittest/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"/>
188 <!-- Run PHP Code Sniffer -->
189 <target name="phpcs">
190 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
191 <fileset dir="${basedir}">
192 <include name="**/*.php" />
193 <exclude name="**/vendor/**" />
195 <formatter type="default" usefile="false"/>
199 <!-- Run PHP Code Sniffer and generate checkstyle.xml -->
200 <target name="phpcs-log">
201 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
202 <fileset dir="${basedir}">
203 <include name="**/*.php" />
204 <exclude name="**/vendor/**" />
206 <formatter type="default" usefile="false"/>
207 <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
211 <!-- Run PHP Mess Detector -->
212 <target name="phpmd">
213 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**" passthru="true"/>
216 <!-- Run PHP Mess Detector and generate pmd.xml -->
217 <target name="phpmd-log">
218 <exec command="phpmd ${basedir} xml codesize,unusedcode --exclude=**/vendor/** --reportfile ${builddir}/logs/pmd.xml" passthru="true"/>
221 <!-- Run PHP Copy/Paste Detector and generate pmd.xml -->
222 <target name="phpcpd-log">
224 <fileset dir="${basedir}">
225 <include name="**/*.php" />
226 <exclude name="**/vendor/**" />
228 <formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
232 <!-- Run PHP Depend and generate jdepend.xml -->
233 <target name="pdepend-log">
235 <fileset dir="${basedir}">
236 <include name="**/*.php" />
237 <exclude name="**/vendor/**" />
239 <logger type="jdepend-xml" outfile="${builddir}/logs/jdepend.xml"/>
240 <!--<analyzer type="coderank-mode" value="method"/>-->
244 <!-- Run PHP CodeBrowser and generate output -->
245 <target name="phpcb-log">
246 <exec command="phpcb --log ${builddir}/logs --source ${basedir} --output ${builddir}/code-browser" passthru="true"/>
249 <!-- Build a release .zip -->
251 <!-- Pick an appropriate dist filename -->
253 <isset property="dist.filename" />
257 <!-- basically - are we running inside hudson? -->
258 <isset property="env.BUILD_NUMBER" />
259 <isset property="env.JOB_NAME" />
262 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
265 <property name="dist.filename" value="kohana" />
271 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
272 <fileset dir="${basedir}">
273 <include name="**/**"/>
275 <exclude name="*.zip" />
276 <exclude name="build/**" />
278 <exclude name="build.xml" />
279 <exclude name="phpunit.xml" />
281 <exclude name="**/.git/**" />
282 <exclude name="**/.git*" />
287 <!-- Hudson CI target -->
288 <target name="ci" depends="clean">
289 <phingcall target="test-log"/>
290 <phingcall target="pdepend-log"/>
291 <phingcall target="phpmd-log"/>
292 <phingcall target="phpcpd-log"/>
293 <phingcall target="phpcs-log"/>
294 <phingcall target="phpcb-log"/>