-
Notifications
You must be signed in to change notification settings - Fork 39
/
build.xml
507 lines (449 loc) · 20.6 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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
<project name="services-trunk" default="package" basedir=".">
<description>Collectionspace Services</description>
<!-- environment should be declared before reading build.properties -->
<property environment="env" />
<!-- set global properties for this build -->
<property file="build.properties" />
<property name="mvn.opts" value="-V" />
<property name="src" location="src" />
<condition property="osfamily-unix">
<os family="unix" />
</condition>
<condition property="osfamily-windows">
<os family="windows" />
</condition>
<target name="init">
<!-- Create the time stamp -->
<tstamp />
</target>
<target name="dist" depends="package" description="generate cspace service distribution">
<!-- Create the distribution directory -->
<mkdir dir="${basedir}/dist" />
<!-- copy db scripts, etc. -->
<copy todir="${basedir}/${dist.server.cspace}/cspace/services">
<fileset dir="${src}/main/resources/scripts" />
</copy>
<!-- copy datasources -->
<copy todir="${basedir}/${dist.deploy.cspace}">
<fileset dir="${src}/main/resources/config/${db}" />
</copy>
<ant antfile="3rdparty/build.xml" target="dist" inheritAll="false" />
<ant antfile="services/build.xml" target="dist" inheritAll="false" />
<ant antfile="cspace-ui/build.xml" target="dist" inheritAll="false" />
<!-- bundle up everything -->
<tar destfile="${basedir}/dist/${cspace.services.release}-${jee.release}.tar.gz" compression="gzip">
<tarfileset dir="${basedir}/dist/cspace" preserveLeadingSlashes="true">
</tarfileset>
</tar>
</target>
<target name="dist-jee-domains" depends="init" description="create JEE distributions for cspace and nuxeo">
<antcall target="dist-jee-cspace" />
<antcall target="dist-jee-nuxeo" />
</target>
<target name="dist-jee-cspace" depends="dist" description="generate JEE distribution for cspace">
<fail message="JEE container is not installed or ${jee.dir} not found">
<condition>
<not>
<available file="${jee.dir}" type="dir" />
</not>
</condition>
</fail>
<fail message="CSpace is not deployed or ${jee.deploy.cspace.services} not found">
<condition>
<not>
<available file="${jee.deploy.cspace.services}" type="file" />
</not>
</condition>
</fail>
<tar destfile="${basedir}/dist/${jee.release}-${domain.cspace}-${release.version}.tar.gz" compression="gzip">
<tarfileset dir="${jee.dir}" prefix="${jee.release}" preserveLeadingSlashes="true">
<exclude name="server/${jee.domain.nuxeo}/**" />
<exclude name="server/${jee.domain.cspace}/log/**" />
<exclude name="server/${jee.domain.cspace}/tmp/**" />
</tarfileset>
</tar>
</target>
<target name="dist-jee-nuxeo" depends="dist" description="generate nuxeo domain distribution">
<fail message="JEE server is not installed or ${jee.dir} not found">
<condition>
<not>
<available file="${jee.dir}" type="dir" />
</not>
</condition>
</fail>
<fail message="Nuxeo is not deployed or ${jee.deploy.nuxeo.plugins} not found">
<condition>
<not>
<available file="${jee.deploy.nuxeo.plugins}" type="dir" />
</not>
</condition>
</fail>
<tar destfile="${basedir}/dist/${jee.release}-${domain.nuxeo}-${release.version}.tar.gz" compression="gzip">
<tarfileset dir="${jee.dir}" prefix="${jee.release}" preserveLeadingSlashes="true">
<exclude name="server/${jee.domain.cspace}/**" />
<exclude name="server/${jee.domain.nuxeo}/log/**" />
<exclude name="server/${jee.domain.nuxeo}/tmp/**" />
</tarfileset>
</tar>
</target>
<target name="package" depends="package-unix,package-windows" description="mvn package" />
<target name="package-unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="package" />
<arg value="-Dmaven.test.skip=true" />
<arg value="-f" />
<arg value="${basedir}/pom.xml" />
<arg value="-N" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="package-windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="package" />
<arg value="-Dmaven.test.skip=true" />
<arg value="-f" />
<arg value="${basedir}/pom.xml" />
<arg value="-N" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="install" depends="install-unix,install-windows" description="mvn install" />
<target name="install-unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="install" />
<arg value="-Dmaven.test.skip=true" />
<arg value="-f" />
<arg value="${basedir}/pom.xml" />
<arg value="-N" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="install-windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="install" />
<arg value="-Dmaven.test.skip=true" />
<arg value="-f" />
<arg value="${basedir}/pom.xml" />
<arg value="-N" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="clean" depends="clean-unix,clean-windows" description="Delete target directories">
<delete dir="${basedir}/build" />
<delete dir="${basedir}/dist" />
</target>
<target name="clean-unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="clean" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="clean-windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="clean" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="test" depends="test-unix,test-windows" description="Run tests" />
<target name="test-unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="test" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="test-windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="test" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="doc" description="Build Java API docs">
<ant antfile="services/build.xml" target="doc" inheritAll="false" />
</target>
<target name="gen_ddl" description="generate service-specific tables(s), indices, etc.">
<ant antfile="services/build.xml" target="gen_ddl" inheritAll="false" />
</target>
<!--
Top-level target to create (or recreate) CollectionSpace related databases. Checks the
'recreate_db' property or environment variable.
-->
<target name="create_db" depends="-set_recreate_db, -no_recreate_db_warn, -recreate_db_warn, -create_db"
description="Creates or recreates CollectionSpace database(s), invoke subtasks for indexes, etc.">
</target>
<!--
This target sets the Ant property 'create_db.recreate' based on the value of the Ant environment variable 'recreate_db'
and the command line property 'recreate_db'. A command line value of 'true' for the 'recreate_db' property will override
the environment variable 'recreate_db' value.
If the environment variable 'recreate_db' is set to true then the Ant property 'create_db.recreate' will get set to true; otherwise,
it will get set to the current value of the Ant property 'recreate_db' -which will be null if not set on the command line.
-->
<target name="-set_recreate_db">
<property environment="env"/>
<condition property="create_db.recreate" else="${recreate_db}" value="true">
<equals arg1="${env.recreate_db}" arg2="true"/>
</condition>
</target>
<!--
This target sends the 'create_nuxeo_db' and 'create_nuxeo_db' targets to all the Ant sub-modules/directories
-->
<target name="-create_db" depends="-validate_create_db_unix, -validate_create_db_windows">
<antcall target="create_nuxeo_db" />
<antcall target="create_cspace_db" />
</target>
<!--
Outputs a warning to the user that existing CollectionSpace databases will be replaced/overridden.
-->
<target name="-no_recreate_db_warn" unless="${create_db.recreate}">
<echo message="The recreate_db property is false or not set. CollectionSpace databases will be created"/>
<echo message="only if they do not exist. To delete all databases and recreate them from scratch, run"/>
<echo message="ant with the argument -Drecreate_db=true, or set the environment variable recreate_db"/>
<echo message="to true."/>
</target>
<!--
Outputs a warning to the user that existing CollectionSpace databases will be replaced/overridden.
-->
<target name="-recreate_db_warn" if="${create_db.recreate}">
<echo message="*** WARNING! The recreate_db property is true. This target will delete all existing CollectionSpace databases."/>
</target>
<target name="-validate_create_db_unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="validate" /> <!-- Ensure proper env vars are set -->
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="-validate_create_db_windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="validate" /> <!-- Ensure proper env vars are set -->
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="drop_nuxeo_db" if="${create_db.recreate}" description="drop nuxeo database">
<echo>Dropping nuxeo databases with user ${db.csadmin.user}</echo>
<sql driver="${db.jdbc.driver.class}" url="${db.jdbc.csadmin.url}" userid="${db.csadmin.user}" password="${db.csadmin.user.password}" autocommit="true" src="${db.script.dir}/drop_nuxeo_db.sql">
<classpath>
<pathelement path="${db.driver.jar}" />
</classpath>
</sql>
</target>
<target name="create_nuxeo_db" depends="drop_nuxeo_db">
<ant antfile="services/build.xml" target="create_nuxeo_db" inheritAll="false" />
</target>
<target name="drop_cspace_db" if="${create_db.recreate}" description="drop cspace database">
<echo>Dropping the cspace database with user ${db.csadmin.user}</echo>
<sql driver="${db.jdbc.driver.class}" url="${db.jdbc.csadmin.url}" userid="${db.csadmin.user}" password="${db.csadmin.user.password}" autocommit="true" src="${db.script.dir}/drop_cspace_db.sql">
<classpath>
<pathelement path="${db.driver.jar}" />
</classpath>
</sql>
</target>
<target name="create_cspace_db" depends="drop_cspace_db">
<echo>Creating the cspace database with user ${db.csadmin.user}</echo>
<!--
The SQL create role/database statements may fail if the cspace role/database already exists. Since the goal of this target
is for the cspace role and database to be created, it's fine if they already exist, so onerror is set to "continue".
-->
<sql driver="${db.jdbc.driver.class}" url="${db.jdbc.csadmin.url}" userid="${db.csadmin.user}" password="${db.csadmin.user.password}" autocommit="true" src="${db.script.dir}/init_cspace_db.sql" onerror="continue">
<classpath>
<pathelement path="${db.driver.jar}" />
</classpath>
</sql>
<ant antfile="services/build.xml" target="create_cspace_db" inheritAll="false" />
</target>
<target name="import" description="import default configuration">
<ant antfile="services/build.xml" target="import" inheritAll="false" />
</target>
<target name="deploy" depends="install, setup_initdb.sql" description="deploy services in ${jee.server.cspace}">
<!-- copy db scripts, etc. -->
<copy todir="${jee.server.cspace}/cspace/services/scripts">
<fileset dir="${src}/main/resources/scripts/" />
</copy>
<ant antfile="3rdparty/build.xml" target="deploy" inheritAll="false" />
<ant antfile="services/build.xml" target="deploy" inheritAll="false" />
<ant antfile="cspace-ui/build.xml" target="deploy" inheritAll="false" />
</target>
<target name="setup_initdb.sql" description="copy init_db scripts, replacing keywords">
<mkdir dir="${jee.server.cspace}/cspace/services/db/postgresql"/>
<copy todir="${jee.server.cspace}/cspace/services/db/postgresql">
<fileset dir="${jee.server.cspace}/cspace/services/db/postgresql" includes="drop_cspace_db.sql, init_cspace_db.sql, drop_nuxeo_db.sql">
<present targetdir="${src}/main/resources/db/postgresql" />
</fileset>
<globmapper from="*" to="*.bak" />
</copy>
<copy todir="${jee.server.cspace}/cspace/services/db" overwrite="false">
<fileset dir="${src}/main/resources/db" />
<filterset>
<filter token="DB_CSADMIN_NAME" value="${db.csadmin.name}" />
<filter token="DB_CSADMIN_USER" value="${db.csadmin.user}" />
<filter token="DB_CSADMIN_PASSWORD" value="${env.DB_CSADMIN_PASSWORD}" />
<!-- Note: double-subs from ${db.xyz.password} fail -->
<filter token="DB_CSPACE_NAME" value="${db.cspace.name}" />
<filter token="DB_CSPACE_USER" value="${db.cspace.user}" />
<filter token="DB_CSPACE_PASSWORD" value="${env.DB_CSPACE_PASSWORD}" />
<!-- Note: double-subs from ${db.xyz.password} fail -->
<filter token="DB_NUXEO_NAME" value="${db.nuxeo.name}" />
<filter token="DB_NUXEO_USER" value="${db.nuxeo.user}" />
<filter token="DB_NUXEO_PASSWORD" value="${env.DB_NUXEO_PASSWORD}" />
<!-- Note: double-subs from ${db.xyz.password} fail -->
<filter token="DB_READER_USER" value="${db.reader.user}" />
<filter token="DB_READER_PASSWORD" value="${env.DB_READER_PASSWORD}" />
<!-- Note: double-subs from ${db.xyz.password} fail -->
</filterset>
</copy>
</target>
<target name="undeploy" description="undeploy services from ${jee.server.cspace}">
<ant antfile="services/build.xml" target="undeploy" inheritAll="false" />
<ant antfile="3rdparty/build.xml" target="undeploy" inheritAll="false" />
<ant antfile="cspace-ui/build.xml" target="undeploy" inheritAll="false" />
<delete failonerror="false" dir="${jee.server.cspace}/cspace/services/config" />
<delete failonerror="false" dir="${jee.server.cspace}/cspace/services/scripts" />
<delete failonerror="false" dir="${jee.server.cspace}/cspace/services/db/jdbc_drivers" />
<delete failonerror="false" dir="${jee.server.cspace}/cspace/services/db/postgresql/upgrade" />
<delete failonerror="false">
<fileset dir="${jee.server.cspace}/cspace/config/services" excludes="local/**" />
</delete>
<!-- Delete mysql-ds.xml to clean up pre-1.8 bundles -->
<delete failonerror="false" file="${jee.deploy.cspace}/mysql-ds.xml" />
<delete failonerror="false" file="${jee.deploy.cspace}/jee-ds.xml" />
<delete failonerror="false" file="${jee.deploy.cspace}/cspace-ds.xml" />
</target>
<target name="hotdeploy" depends="install" description="deploy services in running ${jee.server.cspace}">
<ant antfile="services/build.xml" target="hotdeploy" inheritAll="false" />
</target>
<target name="eclipse" depends="eclipse-unix,eclipse-windows" description="Generate Eclipse files" />
<target name="eclipse-unix" if="osfamily-unix">
<exec executable="mvn" failonerror="true">
<arg value="eclipse:clean" />
<arg value="eclipse:eclipse" />
<arg value="${mvn.opts}" />
</exec>
<exec executable="fixeclipse" failonerror="true" />
</target>
<target name="eclipse-windows" if="osfamily-windows">
<exec executable="cmd" failonerror="true">
<arg value="/c" />
<arg value="mvn" />
<arg value="eclipse:clean" />
<arg value="eclipse:eclipse" />
<arg value="${mvn.opts}" />
</exec>
</target>
<!-- ################################################
Tenant management-related properties and targets
################################################ -->
<!-- Location of the 'tenants' directory for this CollectionSpace source code layer. -->
<property name="src.dir" value="${basedir}" />
<property name="tenants.dir" value="${src.dir}/services/common/src/main/cspace/config/services/tenants"/>
<property name="ui.dir" value="${src.dir}/cspace-ui"/>
<!-- Imports a set of utility routines for managing tenant folders
from a separate Ant buildfile.
See http://wiki.apache.org/ant/NewAntFeaturesInDetail/Import -->
<import file="./tenant-utils-build.xml"/>
<!-- Locations of the tenant folders for the
template tenant and newly-cloned tenant. -->
<property name="template.tenant.dir" value="${tenants.dir}/${template.tenant.shortname}"/>
<property name="tenant.dir" value="${tenants.dir}/${tenant.shortname}"/>
<!-- Location of the tenant bindings delta files for the
template tenant and newly-cloned tenant. -->
<property name="tenant.bindings.delta.suffix" value="-tenant-bindings.delta.xml"/>
<property name="template.bindings.delta.file"
value="${template.tenant.dir}/${template.tenant.shortname}${tenant.bindings.delta.suffix}"/>
<property name="tenant.bindings.delta.file"
value="${tenant.dir}/${tenant.shortname}${tenant.bindings.delta.suffix}"/>
<!-- This target inherits from an existing target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="clone-other-template-files" depends="tenant-utils.clone-other-template-files">
<!-- Clone UI config. -->
<copy todir="${ui.dir}/${tenant.shortname}">
<fileset dir="${ui.dir}/${template.tenant.shortname}"/>
</copy>
</target>
<!-- This target inherits from an existing target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="rename-files-in-cloned-tenant" depends="tenant-utils.rename-files-in-cloned-tenant">
<move todir="${tenants.dir}/${tenant.shortname}" includeemptydirs="false">
<fileset dir="${tenants.dir}/${tenant.shortname}"/>
<mapper type="regexp" from="^(.*?)${template.tenant.shortname}(.*)$" to="\1${tenant.shortname}\2"/>
</move>
</target>
<!-- This target inherits from an (essentially empty) target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="delete-files-in-cloned-tenant"
depends="tenant-utils.delete-files-in-cloned-tenant,
delete-obsolete-tenant-bindings-delta,
delete-merged-tenant-bindings">
</target>
<!-- TODO: Delete the (obsolete) tenant-bindings.delta.xml file, if any,
as this file is used only by CollectionSpace 3.3 and earlier versions. -->
<target name="delete-obsolete-tenant-bindings-delta">
<delete file="${tenant.dir}/tenant-bindings.delta.xml" failonerror="false"/>
</target>
<target name="delete-merged-tenant-bindings">
<delete file="${tenant.dir}/tenant-bindings.merged.xml" failonerror="false"/>
</target>
<!-- This target inherits from an (essentially empty) target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="update-text-in-cloned-tenant"
depends="tenant-utils.update-text-in-cloned-tenant,
update-text-in-tenant-bindings-delta">
</target>
<target name="update-text-in-tenant-bindings-delta"
depends="update-tenant-id-in-tenant-bindings-delta,
remove-enclosing-xml-comments-in-tenant-bindings-delta">
</target>
<target name="update-tenant-id-in-tenant-bindings-delta">
<replaceregexp
file="${tenant.bindings.delta.file}"
match="<tenant:tenantBinding id="(.*)">"
replace="<tenant:tenantBinding id="${tenant.id}">"/>
</target>
<!-- Remove opening and closing XML comment tags, when found
on lines by themselves: the convention currently used
in the tenant bindings delta file. -->
<target name="remove-enclosing-xml-comments-in-tenant-bindings-delta">
<replaceregexp
file="${tenant.bindings.delta.file}"
match="^\s*?<!--\s*$"
replace=""
byline="true"
flags="gm"/>
<replaceregexp
file="${tenant.bindings.delta.file}"
match="^\s*?-->\s*$"
replace=""
byline="true"
flags="gm"/>
</target>
<!-- This target inherits from an (essentially empty) target in the imported
utility routines buildfile, and adds its own behavior specific to this
CollectionSpace source code layer. -->
<target name="check-tenant-extended-properties"
depends="tenant-utils.check-tenant-extended-properties">
<!-- ID of the new tenant to create -->
<antcall target="check-property-is-defined">
<param name="property-to-check" value="tenant.id"/>
</antcall>
<antcall target="check-property-value-is-not-blank">
<param name="property-to-check" value="tenant.id"/>
<param name="property-to-check-value" value="${tenant.id}"/>
</antcall>
<echo message="tenant.id=${tenant.id}"/>
<!-- Internet domain of the new tenant to create
Note: Although this property is included in the provided tenant.properties file
and in documentation, for the purpose of simplicity and consistency across all
three layers, it is not currently used (nor is it checked here) in the Services layer -->
</target>
</project>