Merge branch 'hotfix/3.1.3.1' into 3.1/master
[kohana.git] / build.xml
blob9c2cfd62dd68b67aeef9107b00c6e630ec7c327b
1 <?xml version="1.0" ?>
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 -->
13         <target name="help">
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."/>
25                 <echo message=""/>
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."/>
33                 <echo message=""/>
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"/>
38         </target>
40         <!-- Clean up -->
41         <target name="clean">
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"/>
48         </target>
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" />
56         </target>
58         <target name="git-pull">
59                 <phingcall target="_git-pull">
60                         <property name="dir" value="." />
61                 </phingcall>
62                 <foreach list="${submodules}" param="dir" target="_git-pull"/>
63         </target>
65         <target name="_git-pull">
66                 <exec command="git pull dev" dir="${dir}"/>
67         </target>
69         <target name="git-checkout">
70                 <if>
71                         <not>
72                                 <isset property="git-checkout-branch"/>
73                         </not>
74                         <then>
75                                 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
76                         </then>
77                 </if>
79                 <phingcall target="_git-checkout">
80                         <property name="dir" value="." />
81                 </phingcall>
83                 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
84         </target>
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"/>
88                 <if>
89                         <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
90                         <then>
91                                 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
92                         </then>
93                         <else>
94                                 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
95                         </else>
96                 </if>
97         </target>
99         <target name="git-push">
100                 <foreach list="${submodules}" param="dir" target="_git-push"/>
101                 <phingcall target="_git-push">
102                         <property name="dir" value="." />
103                 </phingcall>
104         </target>
106         <target name="_git-push">
107                 <exec command="git push dev" dir="${dir}" passthru="true"/>
108         </target>
110         <target name="git-status">
111                 <foreach list="${submodules}" param="dir" target="_git-status"/>
112                 <phingcall target="_git-status">
113                         <property name="dir" value="." />
114                 </phingcall>
115         </target>
117         <target name="_git-status">
118                 <exec command="git status" dir="${dir}" passthru="true"/>
119         </target>
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}" />
126                 </phingcall>
127                 <phingcall target="_dev-setup-remote">
128                         <property name="repository" value="git@github.com:kohana/core.git" />
129                         <property name="dir"        value="${basedir}/system" />
130                 </phingcall>
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" />
134                 </phingcall>
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" />
138                 </phingcall>
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" />
142                 </phingcall>
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" />
146                 </phingcall>
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" />
150                 </phingcall>
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" />
154                 </phingcall>
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" />
158                 </phingcall>
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" />
162                 </phingcall>
163         </target>
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}"/>
168         </target>
170         <!-- Run unit tests -->
171         <target name="test">
172                 <exec command="phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
173         </target>
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"/>
178         </target>
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/**" />
186                         </fileset>
187                         <formatter type="default" usefile="false"/>
188                 </phpcodesniffer>
189         </target>
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/**" />
197                         </fileset>
198                         <formatter type="default" usefile="false"/>
199                         <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
200                 </phpcodesniffer>
201         </target>
203         <!-- Run PHP Mess Detector -->
204         <target name="phpmd">
205                 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**"  passthru="true"/>
206         </target>
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"/>
211         </target>
213         <!-- Run PHP Copy/Paste Detector and generate pmd.xml -->
214         <target name="phpcpd-log">
215                 <phpcpd>
216                         <fileset dir="${basedir}">
217                                 <include name="**/*.php" />
218                                 <exclude name="**/vendor/**" />
219                         </fileset>
220                         <formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
221                 </phpcpd>
222         </target>
224         <!-- Run PHP Depend and generate jdepend.xml -->
225         <target name="pdepend-log">
226                 <phpdepend>
227                         <fileset dir="${basedir}">
228                                 <include name="**/*.php" />
229                                 <exclude name="**/vendor/**" />
230                         </fileset>
231                         <logger type="jdepend-xml" outfile="${builddir}/logs/jdepend.xml"/>
232                         <!--<analyzer type="coderank-mode" value="method"/>-->
233                 </phpdepend>
234         </target>
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"/>
239         </target>
241         <!-- Build a release .zip -->
242         <target name="dist">
243                 <!-- Pick an appropriate dist filename -->
244                 <if>
245                         <isset property="dist.filename" />
246                         <else>
247                                 <if>
248                                         <and>
249                                                 <!-- basically - are we running inside hudson? -->
250                                                 <isset property="env.BUILD_NUMBER" />
251                                                 <isset property="env.JOB_NAME" />
252                                         </and>
253                                         <then>
254                                                 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
255                                         </then>
256                                         <else>
257                                                 <property name="dist.filename" value="kohana" />
258                                         </else>
259                                 </if>
260                         </else>
261                 </if>
263                 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
264                         <fileset dir="${basedir}">
265                                 <include name="**/**"/>
266                                 <!-- Build Files -->
267                                 <exclude name="*.zip" />
268                                 <exclude name="build/**" />
269                                 <!-- Dev Files -->
270                                 <exclude name="build.xml" />
271                                 <exclude name="phpunit.xml" />
272                                 <!-- SCM Files -->
273                                 <exclude name="**/.git/**" />
274                                 <exclude name="**/.git*" />
275                         </fileset>
276                 </zip>
277         </target>
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"/>
287         </target>
288 </project>