PHP7 support
[kohana.git] / build.xml
blob8825dac55a491bdf998298b96523c577fb898717
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.3/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 phpcb-log         Run phpcb with logging enabled."/>
23                 <echo message=""/>
24                 <echo message="Kohana Developer Targets"/>
25                 <echo message="========================"/>
26                 <echo message="phing dev-setup         Setup for development on Kohana itself."/>
27                 <echo message="phing git-status        Show the git status of each submodule."/>
28                 <echo message="phing git-checkout      Checkout a branch accross all submodules."/>
29                 <echo message="phing git-pull          Perform a pull for each submodule."/>
30                 <echo message="phing git-push          Perform a push for each submodule."/>
31                 <echo message=""/>
32                 <echo message="Misc Targets"/>
33                 <echo message="============"/>
34                 <echo message="phing ci                Alias task for continuous integration servers"/>
35                 <echo message="phing dist              Build a release .zip"/>
36         </target>
38         <!-- Clean up -->
39         <target name="clean">
40                 <delete dir="${builddir}"/>
41                 <!-- Create build directories -->
42                 <mkdir dir="${builddir}/coverage"/>
43                 <mkdir dir="${builddir}/logs"/>
44                 <mkdir dir="${builddir}/release"/>
45                 <mkdir dir="${builddir}/code-browser"/>
46         </target>
48         <target name="dev-setup">
49                 <property name="git-checkout-branch" value="${branch}"/> <!-- Prevents git-checkout asking for a branch name -->
50                 <exec command="git submodule update --init --recursive" dir="${basedir}" />
51                 <phingcall target="_dev-setup-remotes" />
52                 <phingcall target="git-pull" />
53                 <phingcall target="git-checkout" />
54         </target>
56         <target name="git-pull">
57                 <phingcall target="_git-pull">
58                         <property name="dir" value="." />
59                 </phingcall>
60                 <foreach list="${submodules}" param="dir" target="_git-pull"/>
61         </target>
63         <target name="_git-pull">
64                 <exec command="git pull dev" dir="${dir}"/>
65         </target>
67         <target name="git-checkout">
68                 <if>
69                         <not>
70                                 <isset property="git-checkout-branch"/>
71                         </not>
72                         <then>
73                                 <propertyprompt propertyName="git-checkout-branch" defaultValue="${branch}" promptText="Branch name:" />
74                         </then>
75                 </if>
77                 <phingcall target="_git-checkout">
78                         <property name="dir" value="." />
79                 </phingcall>
81                 <foreach list="${submodules}" param="dir" target="_git-checkout"/>
82         </target>
84         <target name="_git-checkout">
85                 <exec returnProperty="git-checkout-branch-exists" command="git show-ref --quiet --verify -- 'refs/remotes/dev/${git-checkout-branch}'" dir="${dir}"  passthru="true"/>
86                 <if>
87                         <equals arg1="${git-checkout-branch-exists}" arg2="0"/>
88                         <then>
89                                 <exec command="git checkout --track -b ${git-checkout-branch} dev/${git-checkout-branch}" dir="${dir}" passthru="true"/>
90                         </then>
91                         <else>
92                                 <exec command="git checkout -b ${git-checkout-branch}" dir="${dir}" passthru="true"/>
93                         </else>
94                 </if>
95         </target>
97         <target name="git-push">
98                 <foreach list="${submodules}" param="dir" target="_git-push"/>
99                 <phingcall target="_git-push">
100                         <property name="dir" value="." />
101                 </phingcall>
102         </target>
104         <target name="_git-push">
105                 <exec command="git push dev" dir="${dir}" passthru="true"/>
106         </target>
108         <target name="git-status">
109                 <foreach list="${submodules}" param="dir" target="_git-status"/>
110                 <phingcall target="_git-status">
111                         <property name="dir" value="." />
112                 </phingcall>
113         </target>
115         <target name="_git-status">
116                 <exec command="git status" dir="${dir}" passthru="true"/>
117         </target>
119         <target name="_dev-setup-remotes">
120                 <!-- TODO: Clean up... -->
121                 <phingcall target="_dev-setup-remote">
122                         <property name="repository" value="git@github.com:kohana/kohana.git" />
123                         <property name="dir"        value="${basedir}" />
124                 </phingcall>
125                 <phingcall target="_dev-setup-remote">
126                         <property name="repository" value="git@github.com:kohana/core.git" />
127                         <property name="dir"        value="${basedir}/system" />
128                 </phingcall>
129                 <phingcall target="_dev-setup-remote">
130                         <property name="repository" value="git@github.com:kohana/auth.git" />
131                         <property name="dir"        value="${basedir}/modules/auth" />
132                 </phingcall>
133                 <phingcall target="_dev-setup-remote">
134                         <property name="repository" value="git@github.com:kohana/cache.git" />
135                         <property name="dir"        value="${basedir}/modules/cache" />
136                 </phingcall>
137                 <phingcall target="_dev-setup-remote">
138                         <property name="repository" value="git@github.com:kohana/codebench.git" />
139                         <property name="dir"        value="${basedir}/modules/codebench" />
140                 </phingcall>
141                 <phingcall target="_dev-setup-remote">
142                         <property name="repository" value="git@github.com:kohana/database.git" />
143                         <property name="dir"        value="${basedir}/modules/database" />
144                 </phingcall>
145                 <phingcall target="_dev-setup-remote">
146                         <property name="repository" value="git@github.com:kohana/image.git" />
147                         <property name="dir"        value="${basedir}/modules/image" />
148                 </phingcall>
149                 <phingcall target="_dev-setup-remote">
150                         <property name="repository" value="git@github.com:kohana/orm.git" />
151                         <property name="dir"        value="${basedir}/modules/orm" />
152                 </phingcall>
153                 <phingcall target="_dev-setup-remote">
154                         <property name="repository" value="git@github.com:kohana/unittest.git" />
155                         <property name="dir"        value="${basedir}/modules/unittest" />
156                 </phingcall>
157                 <phingcall target="_dev-setup-remote">
158                         <property name="repository" value="git@github.com:kohana/userguide.git" />
159                         <property name="dir"        value="${basedir}/modules/userguide" />
160                 </phingcall>
161         </target>
163         <target name="_dev-setup-remote">
164                 <exec command="git remote rm dev" dir="${dir}"/>
165                 <exec command="git remote add dev ${repository}" dir="${dir}"/>
166         </target>
168         <!-- Run unit tests -->
169         <target name="test">
170                 <exec command="./vendor/phpunit/phpunit/composer/bin/phpunit --bootstrap=modules/unittest/bootstrap_all_modules.php modules/unittest/tests.php" checkreturn="true" passthru="true"/>
171         </target>
174         <!-- Run unit tests and generate junit.xml and clover.xml -->
175         <target name="test-log">
176 <exec command="phpunit --bootstrap=modules/unittest/bootstrap_all_modules.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"/>
177         </target>
179         <!-- Run PHP Code Sniffer -->
180         <target name="phpcs">
181                 <phpcodesniffer standard="Kohana" showSniffs="true" showWarnings="true">
182                         <fileset dir="${basedir}">
183                                 <include name="**/*.php" />
184                                 <exclude name="**/vendor/**" />
185                                 <exclude name="**/tests/**" />
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                                 <exclude name="**/tests/**" />
198                         </fileset>
199                         <formatter type="default" usefile="false"/>
200                         <formatter type="checkstyle" outfile="${builddir}/logs/checkstyle.xml"/>
201                 </phpcodesniffer>
202         </target>
204         <!-- Run PHP Mess Detector -->
205         <target name="phpmd">
206                 <exec command="phpmd '${basedir}' text codesize,unusedcode --exclude=**/vendor/**"  passthru="true"/>
207         </target>
209         <!-- Run PHP Mess Detector and generate pmd.xml -->
210         <target name="phpmd-log">
211                 <exec command="phpmd '${basedir}' xml codesize,unusedcode --exclude=**/vendor/** --reportfile '${builddir}/logs/pmd.xml'"  passthru="true"/>
212         </target>
214         <!-- Run PHP CodeBrowser and generate output -->
215         <target name="phpcb-log">
216                 <exec command="phpcb --exclude='${builddir}/**' --log='${builddir}/logs' --source='${basedir}' --output='${builddir}/code-browser'"  passthru="true"/>
217         </target>
219         <!-- Build a release .zip -->
220         <target name="dist">
221                 <!-- Pick an appropriate dist filename -->
222                 <if>
223                         <isset property="dist.filename" />
224                         <else>
225                                 <if>
226                                         <and>
227                                                 <!-- basically - are we running inside hudson? -->
228                                                 <isset property="env.BUILD_NUMBER" />
229                                                 <isset property="env.JOB_NAME" />
230                                         </and>
231                                         <then>
232                                                 <property name="dist.filename" value="${env.JOB_NAME}-${env.BUILD_NUMBER}" />
233                                         </then>
234                                         <else>
235                                                 <property name="dist.filename" value="kohana" />
236                                         </else>
237                                 </if>
238                         </else>
239                 </if>
241                 <zip destfile="${builddir}/${dist.filename}.zip" prefix="${dist.filename}/">
242                         <fileset dir="${basedir}">
243                                 <include name="**/**"/>
244                                 <!-- Build Files -->
245                                 <exclude name="*.zip" />
246                                 <exclude name="build/**" />
247                                 <!-- Dev Files -->
248                                 <exclude name="build.xml" />
249                                 <exclude name="phpunit.xml" />
250                                 <!-- SCM Files -->
251                                 <exclude name="**/.git/**" />
252                                 <exclude name="**/.git*" />
253                         </fileset>
254                 </zip>
255         </target>
257         <!-- Hudson CI target -->
258         <target name="ci" depends="clean">
259                 <phingcall target="test-log"/>
260                 <phingcall target="pdepend-log"/>
261                 <phingcall target="phpmd-log"/>
262                 <phingcall target="phpcpd-log"/>
263                 <phingcall target="phpcs-log"/>
264                 <phingcall target="phpcb-log"/>
265         </target>
266 </project>