forked from collectionspace/services
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
332 lines (301 loc) · 11.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
<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"/>
<!-- 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.bat" />
<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.bat" />
<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.bat" />
<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.bat" />
<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>
<target name="create_db"
description="create database(s), invoke subtasks for indexes, etc.">
<antcall target="create_nuxeo_db"/>
<antcall target="create_cspace_db"/>
</target>
<target name="create_nuxeo_db"
description="create nuxeo database">
<sql driver="${db.jdbc.driver.class}"
url="${db.jdbc.baseurl}"
userid="${db.user}"
password="${db.user.password}"
autocommit="true"
src="${db.script.dir}/init_nuxeo_db.sql"
>
<classpath>
<pathelement path="${db.driver.jar}"/>
</classpath>
</sql>
<ant antfile="services/build.xml" target="create_nuxeo_db" inheritAll="false"/>
</target>
<target name="create_cspace_db"
description="create cspace database">
<sql driver="${db.jdbc.driver.class}"
url="${db.jdbc.baseurl}"
userid="${db.user}"
password="${db.user.password}"
autocommit="true"
src="${db.script.dir}/init_cspace_db.sql"
>
<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="checkvars,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"/>
</target>
<target name="checkvars">
<fail unless="env.CSPACE_JEESERVER_HOME"
message="Required environment variable CSPACE_JEESERVER_HOME has not been set."/>
<fail unless="env.DB_PASSWORD_CSPACE"
message="Required environment variable DB_PASSWORD_CSPACE has not been set."/>
<fail unless="env.DB_PASSWORD_NUXEO"
message="Required environment variable DB_PASSWORD_NUXEO has not been set."/>
<fail unless="env.DB_PASSWORD"
message="Required environment variable DB_PASSWORD has not been set."/>
</target>
<target name="setup_initdb.sql" description="copy init_db scripts, replacing keywords">
<copy todir="${jee.server.cspace}/cspace/services/db">
<fileset dir="${src}/main/resources/db"/>
<filterset>
<!-- Note: double-subs from ${db.xyz.password} fail -->
<filter token="DB_CSPACE_USER" value="${db.cspace.user}" />
<filter token="DB_NUXEO_USER" value="${db.nuxeo.user}" />
<filter token="DB_CSPACE_PASSWORD" value="${env.DB_PASSWORD_CSPACE}" />
<filter token="DB_NUXEO_PASSWORD" value="${env.DB_PASSWORD_NUXEO}" />
</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"/>
<delete failonerror="false" dir="${jee.server.cspace}/cspace/services"/>
<delete failonerror="false" dir="${jee.server.cspace}/cspace/config/services"/>
<!-- 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.bat" />
<arg value="eclipse:clean" />
<arg value="eclipse:eclipse" />
<arg value="${mvn.opts}" />
</exec>
</target>
<target name="dist_installer" depends="package"
description="Installer: Creates an installer distribution for the CollectionSpace services.">
<!-- copy install scripts, etc. -->
<copy todir="${basedir}/${dist.installer}">
<fileset file="${basedir}/build.properties"/>
<fileset dir="installer"/>
<fileset dir="${src}/main/resources/scripts"/>
</copy>
<ant antfile="services/build.xml" target="dist_installer" inheritAll="false"/>
</target>
</project>