-
Notifications
You must be signed in to change notification settings - Fork 21
/
build.xml
354 lines (313 loc) · 15.8 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<?xml version="1.0" encoding="UTF-8"?>
<project name="opus4server" default="build" xmlns:if="ant:if" xmlns:unless="ant:unless">
<property environment="env" />
<property name="phpVersion" value="8.1" />
<property name="testpath" value="" />
<property name="codingstandard" location="${basedir}/vendor/opus4-repo/codesniffer/ruleset.xml" />
<property name="adminPassword" value="AdminAdmin" />
<property name="bindir" value="${basedir}/vendor/bin" />
<property name="verbose" value="" />
<property name="solrVersion" value="5.5.5" />
<property name="downloadDir" value="${basedir}/downloads" />
<!-- Properties for configuration files (config.ini, console.ini, tests/config.ini) used for testing. -->
<property name="dbName" value="opusdb" />
<property name="dbUserName" value="opus4" />
<property name="dbUserPassword" value="" />
<property name="dbAdminName" value="opus4admin" />
<property name="dbAdminPassword" value="" />
<property name="solrIndexHost" value="localhost" />
<property name="solrIndexPort" value="8983" />
<condition property="solrIndexPath" value="/" else="/solr">
<equals arg1="${phpVersion}" arg2="8.1" />
</condition>
<property name="solrIndexCore" value="opus4" />
<target name="analyse-code" depends="phpcs,phpmd,phpcpd,phploc" />
<target name="build" depends="clean,prepare,lint,pdepend,analyse-code,phpdoc"
description="" />
<target name="build-parallel" depends="prepare,tools-parallel" />
<target name="build-fast" depends="clean,prepare,lint,phpunit-fast" description="" />
<target name="tools-parallel">
<parallel threadCount="2">
<sequential>
<antcall target="pdepend" />
<antcall target="phpmd" />
</sequential>
<antcall target="phpcpd" />
<antcall target="phpcs" />
<antcall target="phploc" />
<antcall target="phpdoc" />
</parallel>
</target>
<target name="clean" depends="clean-cache">
<delete dir="${basedir}/build/logs" />
<delete dir="${basedir}/build/api" />
<delete dir="${basedir}/build/coverage" />
<delete dir="${basedir}/build/pdepend" />
<delete dir="${basedir}/build/code-browser" />
<delete dir="${basedir}/build/release" />
<delete includeemptydirs="true">
<fileset dir="${basedir}/workspace/tmp" includes="**/*" />
</delete>
</target>
<target name="clean-cache">
<delete>
<fileset dir="${basedir}/workspace/cache" includes="*cache*-*" />
</delete>
<delete>
<fileset dir="${basedir}/tests/workspace/cache" includes="*cache*-*" />
</delete>
</target>
<target name="setup" depends="prepare-workspace,prepare-test-workspace,prepare-dependencies,prepare-javascript,prepare-config" />
<target name="prepare-workspace">
<mkdir dir="${basedir}/workspace/cache" />
<mkdir dir="${basedir}/workspace/export" />
<mkdir dir="${basedir}/workspace/filecache" />
<mkdir dir="${basedir}/workspace/files" />
<mkdir dir="${basedir}/workspace/import" />
<mkdir dir="${basedir}/workspace/incoming" />
<mkdir dir="${basedir}/workspace/log" />
<mkdir dir="${basedir}/workspace/tmp" />
<mkdir dir="${basedir}/workspace/tmp/resumption" />
</target>
<target name="prepare-test-workspace">
<mkdir dir="${basedir}/tests/workspace/cache" />
<mkdir dir="${basedir}/tests/workspace/export" />
<mkdir dir="${basedir}/tests/workspace/filecache" />
<mkdir dir="${basedir}/tests/workspace/files" />
<mkdir dir="${basedir}/tests/workspace/import" />
<mkdir dir="${basedir}/tests/workspace/incoming" />
<mkdir dir="${basedir}/tests/workspace/log" />
<mkdir dir="${basedir}/tests/workspace/tmp" />
<mkdir dir="${basedir}/tests/workspace/tmp/resumption" />
</target>
<target name="prepare" depends="clean,prepare-dependencies">
<mkdir dir="${basedir}/build/logs" />
<mkdir dir="${basedir}/build/coverage" />
<mkdir dir="${basedir}/build/api" />
<mkdir dir="${basedir}/build/pdepend" />
</target>
<target name="prepare-dependencies">
<exec executable="php" dir="${basedir}">
<arg value="composer.phar" />
<arg value="update" />
</exec>
<exec executable="${basedir}/bin/install-composer.sh" />
<symlink link="${basedir}/db/schema" resource="${basedir}/vendor/opus4-repo/framework/db/schema"
failonerror="false" />
</target>
<target name="prepare-javascript">
<mkdir dir="${basedir}/public/js" />
<symlink link="${basedir}/public/js/jquery.js" resource="${basedir}/components/jquery/jquery.js"
failonerror="false" />
</target>
<target name="prepare-config" description="Prepares the configuration files">
<!-- Prepare script for rebuilding database. --> <!-- TODO not really necessary anymore -->
<chmod file="${basedir}/tests/rebuilding_database.sh" perm="+x" />
<!-- Prepare test configuration. -->
<copy file="${basedir}/tests/config.ini.template" toFile="${basedir}/tests/config.ini" filtering="true"
overwrite="true">
</copy>
<!-- Prepare main configuration. Needed for scripts like `bin/opus4`. -->
<copy file="${basedir}/application/configs/config.ini.template"
toFile="${basedir}/application/configs/config.ini" filtering="true" overwrite="true">
<filterset>
<filter token="db.user.name" value="${dbUserName}" />
<filter token="db.user.password" value="${dbUserPassword}" />
<filter token="db.admin.name" value="${dbAdminName}" />
<filter token="db.admin.password" value="${dbAdminPassword}" />
<filter token="db.name" value="${dbName}" />
<filter token="searchengine.index.host" value="${solrIndexHost}" />
<filter token="searchengine.index.port" value="${solrIndexPort}" />
<filter token="searchengine.index.path" value="${solrIndexPath}" />
<filter token="searchengine.index.core" value="${solrIndexCore}" />
<filter token="searchengine.extract.host" value="${solrIndexHost}" />
<filter token="searchengine.extract.port" value="${solrIndexPort}" />
<filter token="searchengine.extract.path" value="${solrIndexPath}" />
<filter token="searchengine.extract.core" value="${solrIndexCore}" />
</filterset>
</copy>
<copy file="${basedir}/application/configs/console.ini.template"
toFile="${basedir}/application/configs/console.ini" filtering="true" overwrite="true">
<filterset>
<filter token="db.admin.name" value="${dbAdminName}" />
<filter token="db.admin.password" value="${dbAdminPassword}" />
</filterset>
</copy>
</target>
<target name="lint" description="Prüft, ob PHP Dateien Syntaxfehler enthalten.">
<apply executable="php" dir="${basedir}" failonerror="on" logerror="on">
<arg line="-l"/>
<fileset dir="${basedir}" followsymlinks="false">
<include name="**/*.php" />
<modified />
<exclude name="vendor/**" />
</fileset>
</apply>
</target>
<target name="phploc" description="">
<exec executable="${bindir}/phploc">
<arg value="--log-csv" />
<arg value="${basedir}/build/logs/phploc.csv" />
<arg path="${basedir}/modules" /> <!-- TODO library code -->
</exec>
</target>
<target name="phpdoc">
<exec executable="${bindir}/phpdoc" dir="${basedir}" logerror="on">
<arg value="--directory" />
<arg path="${basedir}/modules" />
<arg value="--target" />
<arg path="${basedir}/build/api" />
</exec>
</target>
<target name="phpcs">
<echo message="Coding Standard = '${codingstandard}'" />
<exec executable="${bindir}/phpcs" dir="${basedir}" output="${basedir}/build/logs/checkstyle.xml"
error="${basedir}/build/logs/checkstyle-error.log">
<arg value="--report=checkstyle" />
<arg value="--standard=${codingstandard}" />
<arg value="--ignore=${basedir}/Opus,${basedir}/Zend" />
<arg path="${basedir}/modules" />
<arg path="${basedir}/library" />
<arg path="${basedir}/scripts" />
</exec>
</target>
<target name="phpmd">
<exec executable="${bindir}/phpmd" dir="${basedir}" logerror="on" output="${basedir}/build/logs/pmd.xml" >
<arg line="--exclude tests,vendor" />
<arg line="." />
<arg line="xml" />
<arg line="codesize,unusedcode,naming,design" />
</exec>
</target>
<target name="phpcpd">
<exec executable="${bindir}/phpcpd" dir="${basedir}" logerror="on" >
<arg line="--min-lines 3" />
<arg line="--min-tokens 30" />
<arg line="--log-pmd ${basedir}/build/logs/pmd-cpd.xml" />
<arg line="./library ./modules ./scripts" />
</exec>
</target>
<target name="pdepend" depends="phpunit" description="Generates software metrics charts.">
<exec executable="${bindir}/pdepend" dir="${basedir}" logerror="on">
<arg line="--coverage-report=${basedir}/build/logs/phpunit.coverage.xml" />
<arg line="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
<arg line="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
<arg line="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
<arg line="--suffix=php,phtml" />
<arg line="--coderank-mode=inheritance,property,method" />
<arg line="--ignore=tests" />
<arg line="${basedir}/library,${basedir}/modules,${basedir}/scripts" />
</exec>
</target>
<target name="phpcb" description="Aggregates tool output with PHP_CodeBrowser.">
<exec executable="${bindir}/phpcb">
<arg value="--log" />
<arg path="${basedir}/build/logs" />
<arg value="--source" />
<arg path="${basedir}/modules" />
<arg value="--output" />
<arg path="${basedir}/build/code-browser" />
</exec>
</target>
<target name="rebuild-database">
<exec executable="./rebuilding_database.sh" dir="${basedir}/tests" failonerror="on">
<arg line="-v" unless:blank="${verbose}"/>
</exec>
</target>
<target name="rebuild-index">
<exec executable="php" dir="${basedir}/bin" failonerror="on">
<arg line="opus4 index:index -v" />
</exec>
</target>
<target name="phpunit" depends="rebuild-database,rebuild-index" description="Runs unit tests with coverage">
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="true">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--coverage-clover ${basedir}/build/logs/phpunit.coverage.xml" />
<arg line="--coverage-html ${basedir}/build/coverage" />
<arg line="--configuration phpunit.xml"/>
<arg line="${testpath}" />
</exec>
</target>
<target name="phpunit-fast" depends="rebuild-database,rebuild-index" description="Runs unit tests without coverage">
<tstamp />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="true">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<!--arg line="-debug" /-->
<arg line="${testpath}" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" />
</exec>
</target>
<target name="test" depends="rebuild-database,rebuild-index" description="Runs all tests in blocks.">
<tstamp />
<echo message="${line.separator}Running 'library' tests ..." />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="false">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<arg line="--testsuite library" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" append="true" />
</exec>
<echo message="${line.separator}Running 'modules' tests (without 'admin') ..." />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="false">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<arg line="--testsuite modules" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" append="true" />
</exec>
<echo message="${line.separator}Running 'admin' module tests ..." />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="false">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<arg line="--testsuite admin" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" append="true" />
</exec>
<echo message="${line.separator}Running 'scripts' tests ..." />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="false">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<arg line="--testsuite scripts" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" append="true" />
</exec>
<echo message="${line.separator}Running 'security' tests ..." />
<exec executable="${bindir}/phpunit" dir="${basedir}/tests" failonerror="false">
<arg line="--log-junit ${basedir}/build/logs/phpunit.xml" />
<arg line="--configuration phpunit.xml" />
<arg line="--testsuite security" />
<redirector output="build/testresult-${DSTAMP}-${TSTAMP}.txt" alwayslog="true" append="true" />
</exec>
</target>
<target name="reset-testdata" depends="rebuild-database,rebuild-index,clean-cache">
</target>
<target name="demo-reset" depends="rebuild-database,demo-prepare-docs,rebuild-index,demo-reset-password">
</target>
<target name="demo-reset-password">
<exec executable="php" dir="${basedir}/scripts" failonerror="true">
<arg line="change-password.php" />
<arg line="admin" />
<arg line="${adminPassword}" />
</exec>
</target>
<target name="demo-prepare-docs">
<exec executable="php" dir="${basedir}/scripts" failonerror="true">
<arg line="opus-console.php" />
<arg line="snippets/delete_non-demo_docs.php" />
</exec>
</target>
<target name="remove-hhar-files">
<exec executable="php" dir="${basedir}/scripts" failonerror="true">
<arg line="opus-console.php" />
<arg line="snippets/delete_files.php" />
</exec>
</target>
<target name="download-solr">
<mkdir dir="${downloadDir}" />
<get src="https://archive.apache.org/dist/lucene/solr/${solrVersion}/solr-${solrVersion}.tgz"
dest="${downloadDir}/solr-${solrVersion}.tgz"
skipexisting="true" />
<exec executable="tar" dir="${downloadDir}">
<arg line="xfz" />
<arg line="solr-${solrVersion}.tgz" />
<arg line="-C ${basedir}" />
</exec>
</target>
</project>