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