-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
394 lines (333 loc) · 18 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
<!-- Imports data model jar, runs test cases, and exports jars if successful
The "install" tasks install a new database.
To use these, the database user name you supply in the Properties file
must be trusted. This means having an entry in the pg_hba.conf like:
local all pimsadmin trust
-->
<project default="test" name="pims-web" basedir="."
>
<!-- Properties -->
<property file="${basedir}/conf/Properties" />
<!-- log -->
<property name="log.dir" location="${basedir}/log" />
<!-- work directory -->
<property name="build" location="${basedir}/build" />
<!-- jars directory -->
<property name="jars" value="../jars" />
<!-- ref data -->
<property name="data.src" location="${basedir}/data" />
<!-- web -->
<property name="lib.web.path" location="${basedir}/WebContent/WEB-INF/lib/" />
<property name="propertiesfile" value="${basedir}/WebContent/WEB-INF/conf/Properties" />
<property name="jsp.src" location="${basedir}/WebContent/WEB-INF/src" />
<property name="classes" location="${basedir}/WebContent/WEB-INF/classes" />
<property name="keystore" value="${basedir}/conf/.keystore" />
<!-- java -->
<property name="test.src" location="${basedir}/TestSource" />
<property name="testClasses" location="${basedir}/testClasses" />
<property name="resources" location="${basedir}/resources" />
<property name="lib.path" location="${basedir}/lib" />
<property name="checkstyle" location="${basedir}/conf/checkstyle-duplicate-code.xml" />
<taskdef resource="checkstyletask.properties" classpath="${lib.path}/checkstyle-all-4.3.jar"/>
<!-- directory which emma report will be written to -->
<property name="instr.dir" value="${basedir}/emmainstr" />
<!-- config files TODO put these in WEB-INF/conf/ --><property name="InvitrogenPrimerPlateOrderProperties" value="org/pimslims/command/leeds/primerOrder/InvitrogenPrimerPlateOrder.properties" />
<property name="ErrorMessagesProperties" value="/org/pimslims/presentation/servlet/utils/Properties" />
<property name="applicationResources" value="ApplicationResources.properties" />
<!-- obsolete
<property name="EntryCloneProperties" value="org/pimslims/presentation/leeds/EntryClone_en.properties" />
<property name="DeepFrozenCultureProperties" value="org/pimslims/presentation/leeds/DeepFrozenCulture_en.properties" />
<property name="ForwardPrimerProperties" value="org/pimslims/presentation/leeds/ForwardPrimer_en.properties" />
<property name="PrimerFormProperties" value="org/pimslims/presentation/leeds/PrimerForm_en.properties" />
<property name="ReversePrimerProperties" value="org/pimslims/presentation/leeds/ReversePrimer_en.properties" />
<property name="InvitrogenPrimerPlateOrderProperties" value="org/pimslims/command/leeds/primerOrder/InvitrogenPrimerPlateOrder.properties" />
<property name="LeedsPrimerPlateOrderProperties" value="org/pimslims/command/leeds/primerOrder/LeedsPrimerPlateOrder.properties" />
<property name="matrices" value="org/pimslims/bioinf/util/matrices" />
<property name="LeedsPrimerPlateOrderProperties" value="org/pimslims/command/leeds/primerOrder/LeedsPrimerPlateOrder.properties" /> -->
<!-- <property name="primerOrderTemplate" value="PrimerOrderTemplate.xlt" /> -->
<!-- sql -->
<property name="sql.path" value="${jars}" />
<property name="sql.file.name" value="pims-database.sql" />
<property name="sql.file" value="${sql.path}/${sql.file.name}" />
<property name="sql.data.file.name" value="pims-db-withrefdata.sql" />
<property name="sql.data.file" value="${sql.path}/${sql.data.file.name}" />
<property name="sql.data.example.file.name" value="install-example.sql" />
<property name="sql.data.example.file" value="${sql.path}/${sql.data.example.file.name}" />
<!-- pwebjar.file -->
<property name="pwebjar.filename" value="pims-web.jar" />
<property name="pwebjar.file" value="${build}/${pwebjar.filename}" />
<!-- ............................................................ -->
<!-- java classpaths. -->
<!-- ............................................................ -->
<!-- First, the classes from JavaSource that Emma will instrument -->
<path id="instrument.classpath">
<pathelement location="${classes}" />
</path>
<!-- add libraries -->
<path id="project.classpath">
<path refid="instrument.classpath" />
<fileset dir="${lib.path}">
<include name="*.jar" />
</fileset>
<fileset dir="${lib.web.path}">
<include name="*.jar" />
</fileset>
</path>
<!-- add test classes -->
<path id="test.classpath">
<path refid="project.classpath" />
<pathelement location="${testClasses}" />
</path>
<!-- emma -->
<path id="emma.lib">
<pathelement location="${basedir}/lib/emma.jar" />
<pathelement location="${basedir}/lib/emma_ant.jar" />
</path>
<taskdef resource="emma_ant.properties" classpathref="emma.lib" />
<!-- ============================================================ -->
<!-- Java tasks. -->
<!-- ============================================================ -->
<!-- Compile web application -->
<target name="compile" depends="clean">
<!-- now all the middle layers, but no servlets -->
<javac srcdir="${basedir}/src/presentation" destdir="${classes}" target="1.5" source="1.5" debug="on" encoding="UTF-8"
sourcepath="" nowarn="true"
>
<classpath refid="project.classpath" />
</javac>
<!-- Compile the servlets -->
<javac srcdir="${basedir}/src/servlet" destdir="${classes}" target="1.5" source="1.5" debug="on" encoding="UTF-8"
>
<classpath refid="project.classpath" />
</javac>
<!-- copy some config files TODO put these in WEB-INF/conf/ -->
<copy file="${basedir}/src/presentation/${applicationResources}" tofile="${classes}/${applicationResources}" />
<copy file="${basedir}/src/presentation/${ErrorMessagesProperties}" tofile="${classes}/${ErrorMessagesProperties}" />
<!--
<copy file="${basedir}/src/presentation/${EntryCloneProperties}" tofile="${classes}/${EntryCloneProperties}" />
<copy file="${basedir}/src/presentation/${DeepFrozenCultureProperties}" tofile="${classes}/${DeepFrozenCultureProperties}" />
<copy file="${basedir}/src/presentation/${PrimerFormProperties}" tofile="${classes}/${PrimerFormProperties}" />
<copy file="${basedir}/src/presentation/${LeedsPrimerPlateOrderProperties}" tofile="${classes}/${LeedsPrimerPlateOrderProperties}" />
<copy file="${basedir}/src/presentation/${ForwardPrimerProperties}" tofile="${classes}/${ForwardPrimerProperties}" />
<copy file="${basedir}/src/presentation/${ReversePrimerProperties}" tofile="${classes}/${ReversePrimerProperties}" />
<copy file="${basedir}/src/presentation/${InvitrogenPrimerPlateOrderProperties}" tofile="${classes}/${InvitrogenPrimerPlateOrderProperties}" />
-->
<copy file="${basedir}/conf/displaytag.properties" tofile="${classes}/displaytag.properties" />
<!-- <copy file="${basedir}/conf/PrimerOrderTemplate.xlt" tofile="${classes}/${primerOrderTemplate}" /> -->
</target>
<!-- TODO
<target name="checkstyle" >
<checkstyle config="${checkstyle}"
maxErrors="15" maxWarnings="1000"
>
<fileset dir="${java.src}" includes="**/*.java" excludes="uk/ac/ebi/**" />
<classpath refid="project.classpath" />
<formatter toFile="${instr.dir}/duplicates.txt" />
</checkstyle>
</target> -->
<!-- Build the JSPs -->
<target name="jspc" description="Build the JSPs">
<dirname property="pwd" file="." />
<echo>Present working directory: ${pwd}</echo>
<delete dir="${classes}/org/apache" />
<delete dir="${jsp.src}" />
<taskdef classname="org.apache.jasper.JspC" name="jasper2" >
<classpath refid="project.classpath" />
</taskdef>
<jasper2
validateXml="false"
uriroot="${basedir}/WebContent/"
webXmlFragment="${basedir}/WebContent/WEB-INF/pims-jsps.xml"
outputDir="${jsp.src}"
/>
<javac srcdir="${jsp.src}" destdir="${classes}" target="1.5" source="1.5"
debug="no" encoding="UTF-8" memoryMaximumSize="1024m"
excludes="**/*.smap"
>
<classpath refid="project.classpath" />
<include name="**" />
<exclude name="tags/**" />
</javac>
<!-- see http://tomcat.apache.org/tomcat-6.0-doc/jasper-howto.html -->
</target>
<!-- Export the war file -->
<!-- TODO could jar up the servlets to keep this neater -->
<!-- must compile first, in case emma has modified the class files -->
<!-- TODO depends="compile,jspc" -->
<target name="war" depends="compile" description="make the war file">
<jar index="true" destfile="${jars}/pims.war" basedir="${basedir}/WebContent" manifest="conf/pims-war.mf"
excludes="mockups/**,WEB-INF/conf/Properties,**/Test*.class,**/AbstractTest*.class"
/>
<!-- TODO exclude help/**,WEB-INF/JSP/** -->
<!-- <jar index="true" destfile="${jars}/pims-api.jar" basedir="${classes}"
manifest="conf/pims-api.mf"
excludes="**/Test*.class,**/AbstractTest*.class"
/> -->
</target>
<!-- It would be nice to make this include the compiled jsps,
but there are two problems.
Firstly, pages with custom tags don't work, for reasons I cant understand (Chris)
Secondly, the results are specific to Tomcat, and may not work in other containers.
-->
<target name="jar" depends="compile" description="Make the jar file for pims-web">
<echo>tar file: ${pwebjar.file}</echo>
<jar index="true" destfile="${pwebjar.file}">
<fileset dir="${classes}" />
</jar>
<!-- now in ../build.xml
<copy overwrite="true" verbose="true" file="${pwebjar.file}" tofile="../tools/lib/${pwebjar.filename}" />
-->
</target>
<!-- ============================================================ -->
<!-- Test case tasks. -->
<!-- ============================================================ -->
<target name="compileTest" depends="compile">
<javac srcdir="${test.src}" destdir="${testClasses}" target="1.5" source="1.5" deprecation="false" debug="on" encoding="UTF-8">
<classpath refid="test.classpath" />
</javac>
</target>
<target name="test" ><!-- depends="compileTest" -->
<emma enabled="true">
<instr instrpathref="instrument.classpath" mode="overwrite" metadatafile="${instr.dir}/metadata.emma" merge="true">
<!--
Could have <filter value="${emma.filter}" />
-->
</instr>
</emma>
<junit haltonfailure="true" haltonerror="true" fork="true" dir="${basedir}" forkmode="once">
<!-- <jvmarg value="-server" /> -->
<jvmarg value="-enableassertions" />
<jvmarg value="-Xms512m" />
<jvmarg value="-Xmx512m" />
<jvmarg value="-Demma.coverage.out.file=${instr.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=false" />
<classpath refid="test.classpath" />
<formatter type="brief" usefile="false" />
<test name="org.pimslims.AllWebTests" />
<sysproperty key="TestingDataPath" value="${data.src}"/>
</junit>
<!-- TODO <emma enabled="true">
<report sourcepath="${java.src}" sort="-block,-name,-method,-class" metrics="method:10,block:50,line:50,class:10">
<infileset dir="${instr.dir}" includes="*.em, *.ec, *.emma" />
<txt outfile="${instr.dir}/coverage.txt" depth="all" columns="line,name,class,method,block" metrics="method:0,block:0,line:0,class:0" />
<html outfile="${instr.dir}/coverage.html" depth="method" columns="name,class,method,block,line" />
</report>
</emma> -->
</target>
<!-- ============================================================ -->
<!-- Database tasks -->
<!-- ============================================================ -->
<target name="createdb" description="Creates the database.">
<exec failOnError="true" executable="createdb"><arg line="--encoding UTF8 -U ${db.username} '${db.name}' " /></exec>
</target>
<target name="dropdb" description="Drops the database.">
<echo>dropdb -U ${db.username} '${db.name}'</echo>
<exec failOnError="false" executable="dropdb"><arg line="-U ${db.username} '${db.name}'" /></exec>
</target>
<target name="install-emptydb" description="Create new empty db by loading schema.">
<antcall target="dropdb"/>
<antcall target="createdb"/>
<antcall target="cleanLog"/>
<echo>Installing database with ${sql.file}, see ${log.dir}/install-emptydb.out</echo>
<exec output="${log.dir}/install-emptydb.out" failOnError="true" executable="psql"><arg line="-q -U ${db.username} -d ${db.name} -f ${sql.file}"/></exec>
<echo> >>> ${sql.file} loaded into DB ${db.name}</echo>
</target>
<target name="install-refdatadb" description="Install db with ref data." depends="">
<antcall target="dropdb" />
<antcall target="createdb" />
<mkdir dir="${log.dir}" />
<echo>Installing database with ${sql.data.file}, see ${log.dir}/install-refdatadb.out</echo>
<exec output="${log.dir}/install-refdatadb.out" failOnError="true" executable="psql">
<arg line="-q -U ${db.username} -d ${db.name} -f ${sql.data.file}" />
</exec>
</target>
<target name="installdbexample" description="Install example db." depends="">
<antcall target="dropdb" />
<antcall target="createdb" />
<mkdir dir="${log.dir}" />
<echo>Installing database with ${sql.data.example.file}, see ${log.dir}/install-db-example.out</echo>
<exec output="${log.dir}/install-db-example.out" failOnError="true" executable="psql">
<arg line="-q -U ${db.username} -d ${db.name} -f ${sql.data.example.file}" />
</exec>
</target>
<target name="dump-db" description="Dump db into install-hb-withrefdata.sql." depends="">
<exec failOnError="true" executable="pg_dump"><arg line="-U ${db.username} --no-owner -f ${sql.data.file} ${db.name}"/></exec>
<echo> >>> Database ${db.name} exported into ${sql.data.file}</echo>
<antcall target="install-refdatadb" />
</target>
<target name="dumpdbexample" description="Dump db into install-example.sql." depends="">
<exec failOnError="true" executable="pg_dump">
<arg line="-U ${db.username} --no-owner -f ${sql.data.example.file} ${db.name}" />
</exec>
<antcall target="installdbexample" />
</target>
<!-- ============================================================ -->
<!-- Clean tasks -->
<!-- ============================================================ -->
<!-- Clean temp directories -->
<target name="clean">
<delete dir="${classes}" />
<mkdir dir="${classes}" />
<delete dir="${testClasses}" />
<mkdir dir="${testClasses}" />
<delete dir="${jsp.src}" />
<mkdir dir="${jsp.src}" />
<delete dir="${instr.dir}" />
<mkdir dir="${instr.dir}" />
</target>
<target name="cleanLog" description="Clean log dirrectory.">
<delete dir="${log.dir}" />
<mkdir dir="${log.dir}" />
</target>
<!-- ============================================================ -->
<!-- PIMS other tasks -->
<!-- ============================================================ -->
<!-- optional: import current jars from other projects -->
<target name="import">
<copy file="${jars}/pims-model.jar" tofile="${lib.web.path}/pims-model.jar" />
</target>
<!-- optional: PIMS-25 construct a pims-web.jar for use by -->
<!-- pims-dependent but non-webapp code -->
<target name="pimswebjar">
<jar index="true" destfile="${jars}/pims-web.jar" basedir="${classes}" excludes="" />
</target>
<target name="genkeystore" description="generate a keystore">
<delete file="${keystore}" />
<genkey alias="pims" storepass="secret" keystore="${keystore}">
<dname>
<param name="CN" value="PiMS"/>
<param name="OU" value="PiMS Development Team"/>
<param name="O" value="PiMS"/>
<param name="C" value="UK"/>
</dname>
</genkey>
</target>
<target name="pims-lib.jar" description="generate a single jar file containing all the third party libraries that will be part of the deliverable">
<!-- first make a temporary jar with all the files in it -->
<jar index="true" jarfile="${build}/pims-lib.jar" >
<zipgroupfileset dir="${lib.web.path}" >
<include name="*.jar" />
</zipgroupfileset>
</jar>
<!-- then exclude the signature files, you can't merge two signed jars -->
<jar jarfile="${jars}/pims-lib.jar"
index="true"
filesetmanifest="skip"
>
<zipfileset src="${build}/pims-lib.jar">
<exclude name="META-INF/*.SF"/>
</zipfileset>
</jar>
<!-- could
<signjar destdir="${jars}/signed"
alias="pims"
keystore="${keystore}"
storepass="secret">
<path>
<fileset dir="${jars}" includes="pims-lib.jar" />
</path>
<flattenmapper />
</signjar> -->
</target>
<!-- TODO commit, deploy, install conf/Properties -->
</project>