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.1/develop"/>
10 <property name="submodules" value="system,modules/auth,modules/cache,modules/codebench,modules/database,modules/image,modules/orm,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/orm.git" />
153 <property name="dir" value="${basedir}/modules/orm" />
155 <phingcall target="_dev-setup-remote">
156 <property name="repository" value="git@github.com:kohana/unittest.git" />
157 <property name="dir" value="${basedir}/modules/unittest" />
159 <phingcall target="_dev-setup-remote">
160 <property name="repository" value="git@github.com:kohana/userguide.git" />
161 <property name="dir" value="${basedir}/modules/userguide" />
165 <target name="_dev-setup-remote">
166 <exec command="git remote rm dev" dir="${dir}"/>
167 <exec command="git remote add dev ${repository}" dir="${dir}"/>
170 <!-- Run unit tests -->
172 <exec command="phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
175 <!-- Run unit tests and generate junit.xml and clover.xml -->
176 <target name="test-log">
177 <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"/>
180 <!-- Run PHP Code Sniffer -->
181 <target name="phpcs">
182 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
183 <fileset dir="${basedir}">
184 <include name="**/*.php" />
185 <exclude name="**/vendor/**" />
187 <formatter type="default" usefile="false"/>
191 <!-- Run PHP Code Sniffer and generate checkstyle.xml -->
192 <target name="phpcs-log">
193 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
194 <fileset dir="${basedir}">
195 <include name="**/*.php" />
196 <exclude name="**/vendor/**" />
198 <formatter type="default" usefile="false"/>
199 <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
203 <!-- Run PHP Mess Detector -->
204 <target name="phpmd">
205 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**" passthru="true"/>
208 <!-- Run PHP Mess Detector and generate pmd.xml -->
209 <target name="phpmd-log">
210 <exec command="phpmd ${basedir} xml codesize,unusedcode --exclude=**/vendor/** --reportfile ${builddir}/logs/pmd.xml" passthru="true"/>
213 <!-- Run PHP Copy/Paste Detector and generate pmd.xml -->
214 <target name="phpcpd-log">
216 <fileset dir="${basedir}">
217 <include name="**/*.php" />
218 <exclude name="**/vendor/**" />
220 <formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
224 <!-- Run PHP Depend and generate jdepend.xml -->
225 <target name="pdepend-log">
227 <fileset dir="${basedir}">
228 <include name="**/*.php" />
229 <exclude name="**/vendor/**" />
231 <logger type="jdepend-xml" outfile="${builddir}/logs/jdepend.xml"/>
232 <!--<analyzer type="coderank-mode" value="method"/>-->
236 <!-- Run PHP CodeBrowser and generate output -->
237 <target name="phpcb-log">
238 <exec command="phpcb --log ${builddir}/logs --source ${basedir} --output ${builddir}/code-browser" passthru="true"/>
241 <!-- Build a release .zip -->
243 <!-- Pick an appropriate dist filename -->
245 <isset property="dist.filename" />
249 <!-- basically - are we running inside hudson? -->
250 <isset property="env.BUILD_NUMBER" />
251 <isset property="env.JOB_NAME" />
254 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
257 <property name="dist.filename" value="kohana" />
263 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
264 <fileset dir="${basedir}">
265 <include name="**/**"/>
267 <exclude name="*.zip" />
268 <exclude name="build/**" />
270 <exclude name="build.xml" />
271 <exclude name="phpunit.xml" />
273 <exclude name="**/.git/**" />
274 <exclude name="**/.git*" />
279 <!-- Hudson CI target -->
280 <target name="ci" depends="clean">
281 <phingcall target="test-log"/>
282 <phingcall target="pdepend-log"/>
283 <phingcall target="phpmd-log"/>
284 <phingcall target="phpcpd-log"/>
285 <phingcall target="phpcs-log"/>
286 <phingcall target="phpcb-log"/>