tracking submodules
[kohana.git] / build.xml
blob4f2499efd8a15a9c8687c817a81fb4ded55339f4
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         </target>
39         <!-- Clean up -->
40         <target name="clean">
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"/>
47         </target>
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" />
55         </target>
57         <target name="git-pull">
58                 <phingcall target="_git-pull">
59                         <property name="dir" value="." />
60                 </phingcall>
61                 <foreach list="${submodules}" param="dir" target="_git-pull"/>
62         </target>
64         <target name="_git-pull">
65                 <exec command="git pull dev" dir="${dir}"/>
66         </target>
68         <target name="git-checkout">
69                 <if>
70                         <not>
71                                 <isset property="git-checkout-branch"/>
72                         </not>
73                         <then>
74                                 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
75                         </then>
76                 </if>
78                 <phingcall target="_git-checkout">
79                         <property name="dir" value="." />
80                 </phingcall>
82                 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
83         </target>
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"/>
87                 <if>
88                         <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
89                         <then>
90                                 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
91                         </then>
92                         <else>
93                                 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
94                         </else>
95                 </if>
96         </target>
98         <target name="git-push">
99                 <foreach list="${submodules}" param="dir" target="_git-push"/>
100                 <phingcall target="_git-push">
101                         <property name="dir" value="." />
102                 </phingcall>
103         </target>
105         <target name="_git-push">
106                 <exec command="git push dev" dir="${dir}" passthru="true"/>
107         </target>
109         <target name="git-status">
110                 <foreach list="${submodules}" param="dir" target="_git-status"/>
111                 <phingcall target="_git-status">
112                         <property name="dir" value="." />
113                 </phingcall>
114         </target>
116         <target name="_git-status">
117                 <exec command="git status" dir="${dir}" passthru="true"/>
118         </target>
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}" />
125                 </phingcall>
126                 <phingcall target="_dev-setup-remote">
127                         <property name="repository" value="git@github.com:kohana/core.git" />
128                         <property name="dir"        value="${basedir}/system" />
129                 </phingcall>
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" />
133                 </phingcall>
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" />
137                 </phingcall>
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" />
141                 </phingcall>
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" />
145                 </phingcall>
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" />
149                 </phingcall>
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" />
153                 </phingcall>
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" />
157                 </phingcall>
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" />
161                 </phingcall>
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" />
165                 </phingcall>
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" />
169                 </phingcall>
170         </target>
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}"/>
175         </target>
177         <!-- Run unit tests -->
178         <target name="test">
179                 <exec command="phpunit --bootstrap=application/test_bootstrap.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
180         </target>
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"/>
185         </target>
187         <!-- Run PHP Code Sniffer -->
188         <target name="phpcs">
189                 <exec command="phpcs --standard=Kohana --ignore=*.js,*.css,**/vendor/**,**/tests/** ${basedir}" passthru="true"/>
190         </target>
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"/>
195         </target>
197         <!-- Run PHP Mess Detector -->
198         <target name="phpmd">
199                 <exec command="phpmd ${basedir} text codesize,unusedcode --exclude=**/vendor/**"  passthru="true"/>
200         </target>
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"/>
205         </target>
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"/>
210         </target>
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"/>
215         </target>
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"/>
220         </target>
222         <!-- Build a release .zip -->
223         <target name="dist">
224                 <!-- Pick an appropriate dist filename -->
225                 <if>
226                         <isset property="dist.filename" />
227                         <else>
228                                 <if>
229                                         <and>
230                                                 <!-- basically - are we running inside hudson? -->
231                                                 <isset property="env.BUILD_NUMBER" />
232                                                 <isset property="env.JOB_NAME" />
233                                         </and>
234                                         <then>
235                                                 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
236                                         </then>
237                                         <else>
238                                                 <property name="dist.filename" value="kohana" />
239                                         </else>
240                                 </if>
241                         </else>
242                 </if>
244                 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
245                         <fileset dir="${basedir}">
246                                 <include name="**/**"/>
247                                 <!-- Build Files -->
248                                 <exclude name="*.zip" />
249                                 <exclude name="build/**" />
250                                 <!-- Dev Files -->
251                                 <exclude name="build.xml" />
252                                 <exclude name="phpunit.xml" />
253                                 <!-- SCM Files -->
254                                 <exclude name="**/.git/**" />
255                                 <exclude name="**/.git*" />
256                         </fileset>
257                 </zip>
258         </target>
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"/>
268         </target>
269 </project>