tracking submodules for 3.0.11
[kohana.git] / build.xml
blob98303081f67c02af7162d63c1298911ba1ede781
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.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 -->
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/oauth.git" />
153                         <property name="dir"        value="${basedir}/modules/oauth" />
154                 </phingcall>
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" />
158                 </phingcall>
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" />
162                 </phingcall>
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" />
166                 </phingcall>
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" />
170                 </phingcall>
171         </target>
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}"/>
176         </target>
178         <!-- Run unit tests -->
179         <target name="test">
180                 <exec command="phpunit --bootstrap=modules/unittest/bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
181         </target>
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"/>
186         </target>
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/**" />
194                         </fileset>
195                         <formatter type="default" usefile="false"/>
196                 </phpcodesniffer>
197         </target>
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/**" />
205                         </fileset>
206                         <formatter type="default" usefile="false"/>
207                         <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
208                 </phpcodesniffer>
209         </target>
211         <!-- Run PHP Mess Detector -->
212         <target name="phpmd">
213                 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**"  passthru="true"/>
214         </target>
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"/>
219         </target>
221         <!-- Run PHP Copy/Paste Detector and generate pmd.xml -->
222         <target name="phpcpd-log">
223                 <phpcpd>
224                         <fileset dir="${basedir}">
225                                 <include name="**/*.php" />
226                                 <exclude name="**/vendor/**" />
227                         </fileset>
228                         <formatter type="pmd" outfile="${builddir}/logs/pmd-cpd.xml"/>
229                 </phpcpd>
230         </target>
232         <!-- Run PHP Depend and generate jdepend.xml -->
233         <target name="pdepend-log">
234                 <phpdepend>
235                         <fileset dir="${basedir}">
236                                 <include name="**/*.php" />
237                                 <exclude name="**/vendor/**" />
238                         </fileset>
239                         <logger type="jdepend-xml" outfile="${builddir}/logs/jdepend.xml"/>
240                         <!--<analyzer type="coderank-mode" value="method"/>-->
241                 </phpdepend>
242         </target>
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"/>
247         </target>
249         <!-- Build a release .zip -->
250         <target name="dist">
251                 <!-- Pick an appropriate dist filename -->
252                 <if>
253                         <isset property="dist.filename" />
254                         <else>
255                                 <if>
256                                         <and>
257                                                 <!-- basically - are we running inside hudson? -->
258                                                 <isset property="env.BUILD_NUMBER" />
259                                                 <isset property="env.JOB_NAME" />
260                                         </and>
261                                         <then>
262                                                 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
263                                         </then>
264                                         <else>
265                                                 <property name="dist.filename" value="kohana" />
266                                         </else>
267                                 </if>
268                         </else>
269                 </if>
271                 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
272                         <fileset dir="${basedir}">
273                                 <include name="**/**"/>
274                                 <!-- Build Files -->
275                                 <exclude name="*.zip" />
276                                 <exclude name="build/**" />
277                                 <!-- Dev Files -->
278                                 <exclude name="build.xml" />
279                                 <exclude name="phpunit.xml" />
280                                 <!-- SCM Files -->
281                                 <exclude name="**/.git/**" />
282                                 <exclude name="**/.git*" />
283                         </fileset>
284                 </zip>
285         </target>
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"/>
295         </target>
296 </project>