-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.xml
More file actions
540 lines (459 loc) · 21.3 KB
/
build.xml
File metadata and controls
540 lines (459 loc) · 21.3 KB
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
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
<?xml version="1.0" encoding="UTF-8"?>
<project name="ZFIN" default="usage" basedir=".">
<property name="build.sysclasspath" value="ignore"/>
<property name="buildfiles.dir" value="buildfiles"/>
<import file="${buildfiles.dir}/base-properties.xml"/>
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<pathelement location="lib/Java/ant-contrib-0.3.jar"/>
</classpath>
</taskdef>
<property name="commons.dir" value="${basedir}/commons/env"/>
<property environment="env"/>
<!--If INSTANCE system property is not defined,-->
<!--then define from the environment.-->
<condition property="instance.env.defined">
<not>
<equals arg1="${env.INSTANCE}" arg2=""/>
</not>
</condition>
<fail unless="instance.env.defined"
message="INSTANCE must be defined in the environment even if overriden by -DINSTANCE."/>
<!--If INSTANCE system property is not defined,-->
<!--then define from the environment.-->
<condition property="instance.overridden">
<and>
<not>
<equals arg1="${INSTANCE}" arg2="$${INSTANCE}"/>
</not>
<not>
<equals arg1="${env.INSTANCE}" arg2="${INSTANCE}"/>
</not>
</and>
</condition>
<property name="classes.dir.target" value="${env.TARGETROOT}/home/WEB-INF/classes"/>
<property name="lib.dir.target" value="${env.TARGETROOT}/home/WEB-INF/lib"/>
<!--If the INSTANCE variable is not already set (this code gets run for every target, I believe)-->
<!--the we check if it is defined in the system as OVERRIDE_INSTANCE-->
<if>
<equals arg1="${instance.overridden}" arg2="true"/>
<then>
<echo message="!!!!!!!"/>
<echo message="Instance IS system defined and set to '${INSTANCE}'."/>
<echo message="Instance IS defined in environment as '${env.INSTANCE}'."/>
<echo message="!!!!!!!"/>
</then>
<else>
<property name="INSTANCE" value="${env.INSTANCE}"/>
<echo message="INSTANCE = ${INSTANCE}"/>
</else>
</if>
<!--Define property file.-->
<property name="property.file" value="${basedir}/home/WEB-INF/zfin.properties"/>
<property name="log4j.file" value="${commons.dir}/${INSTANCE}.log4j.xml"/>
<!--If the property file is not defined then fail.-->
<!--
<echo message="property file=${property.file}"/>
-->
<!-- Load properties into Ant for build-time use -->
<property file="${property.file}"/>
<!-- ensure git is looking in the source tree directory for hooks -->
<exec executable="git">
<arg value="config" />
<arg value="core.hooksPath" />
<arg value=".githooks" />
</exec>
<!-- Load filters directly from zfin.properties instead of generated allfilter.xml -->
<filterset id="allfilters">
<filtersfile file="${property.file}"/>
</filterset>
<import file="${buildfiles.dir}/properties.xml"/>
<import file="${buildfiles.dir}/gwt.xml"/>
<import file="${buildfiles.dir}/test.xml"/>
<import file="${buildfiles.dir}/performance.xml"/>
<import file="${buildfiles.dir}/tomcat.xml"/>
<import file="${buildfiles.dir}/usage.xml"/>
<import file="${buildfiles.dir}/serialization.xml"/>
<import file="${buildfiles.dir}/warehouse.xml"/>
<import file="${buildfiles.dir}/utilities.xml"/>
<import file="${buildfiles.dir}/jenkins.xml"/>
<import file="${buildfiles.dir}/solr-ant.xml"/>
<import file="${buildfiles.dir}/shipper.xml"/>
<import file="${buildfiles.dir}/base-properties.xml"/>
<!--
<echo message="property file=${LOG4J_FILE}"/>
-->
<!-- ====================================================================== -->
<!-- COMPILE TASKS -->
<!-- ====================================================================== -->
<target name="prepare" depends="hibernate-available" description="Prepares directories for compilation">
<mkdir dir="${classbin.dir}"/>
<mkdir dir="${classbin.dir}/resources"/>
<copy file="${conf.dir}/hibernate.cfg.xml" todir="${classbin.dir}"/>
<copy file="${conf.dir}/mchange-log.properties" todir="${classbin.dir}"/>
<copy file="${commons.dir}/${LOG4J_FILE}" tofile="${web-inf.dir}/classes/log4j2.xml" failonerror="false">
<filterset>
<filter token="DEFAULT_EMAIL" value="${DEFAULT_EMAIL}"/>
</filterset>
</copy>
<copy todir="${classbin.dir}/org/zfin">
<fileset dir="${hibernate.conf.dir}">
<include name="*.hbm.xml"/>
</fileset>
</copy>
<copy todir="${classbin.dir}">
<fileset dir="${source.dir}">
<include name="**/*.properties"/>
</fileset>
</copy>
<if>
<equals arg1="${hibernate.exists}" arg2="true"/>
<then>
<echo message="Hibernate configuration file hibernate.properties found"/>
<copy file="${conf.dir}/hibernate.properties" tofile="${classbin.dir}/hibernate.properties"
failonerror="false"/>
</then>
</if>
<!--
<copy file="${conf.dir}/application.properties" todir="${classbin.dir}/resources"/>
-->
<copy file="${conf.dir}/zfin-messages.properties" tofile="${classbin.dir}/zfin-messages.properties"/>
</target>
<target name="do"
depends="cleanClasses, compile, prepare-properties"
description="Everything to compile excluding jsp files. No copying into target directory"/>
<target name="all" depends="deploy" description="The same as deploy for Tom."/>
<target name="install" depends="deploy" description="Same as deploy."/>
<!-- createEnum is no longer needed - use gradle generatePropertiesEnum instead -->
<target name="createEnum" description="DEPRECATED: Use 'gradle generatePropertiesEnum' instead">
<echo message="createEnum is deprecated."/>
<echo message="In the future use 'gradle generatePropertiesEnum' to regenerate ZfinPropertiesEnum.java"/>
<gradle task="generatePropertiesEnum" />
<echo message="####"/>
<echo message="#### TODO: migrate toward using spring @ConfigurationProperties instead of ZfinPropertiesEnum"/>
</target>
<!-- rebuildPropertiesFromYaml will invoke the groovy script for creating home/WEB-INF/zfin.properties from all-properties.yml -->
<target name="rebuildPropertiesFromYaml" description="Rebuilds zfin.properties from all-properties.yml">
<echo message="Rebuilding ${property.file} from all-properties.yml"/>
<groovy src="${basedir}/commons/env/PropertiesProcessor.groovy">
<arg value="-c"/>
<arg value="${basedir}/commons/env/all-properties.yml"/>
<arg value="-o"/>
<arg value="${property.file}"/>
</groovy>
</target>
<target name="rebuildProperties" depends="rebuildPropertiesFromYaml,createEnum"
description="Rebuilds properties for all instances.">
</target>
<path id="extended.classpath">
<path refid="classpath"/>
<!-- This class needs to come first to ensure that unit test methods are executed in the order they appear in the source file -->
<fileset dir="${lib}">
<include name="junit-orderOfExecution.jar"/>
</fileset>
<fileset dir="${lib}">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
<fileset dir="${gwt.lib}">
<include name="*.jar"/>
</fileset>
<fileset dir="${env.GROOVY_HOME}/lib" erroronmissingdir="false">
<include name="*.jar"/>
</fileset>
</path>
<path id="unittest.classpath">
<!-- This class needs to come first to ensure that unit test methods are executed in the order they appear in the source file -->
<fileset dir="${lib}">
<include name="junit-orderOfExecution.jar"/>
</fileset>
<fileset dir="${lib}">
<include name="*.jar"/>
<include name="*.zip"/>
</fileset>
<fileset dir="${gwt.lib}">
<include name="*.jar"/>
</fileset>
<path refid="classpath"/>
</path>
<target name="writeClassPath">
<pathconvert property="classpathProp1" refid="extended.classpath"/>
<tempfile property="classpathFile1" suffix=".txt" createfile="true" prefix="extended.classpath." destdir="/tmp"/>
<echo file="${classpathFile1}">${classpathProp1}</echo>
<echo>extended.classpath is written to ${classpathFile1}</echo>
<pathconvert property="classpathProp2" refid="unittest.classpath"/>
<tempfile property="classpathFile2" suffix=".txt" createfile="true" prefix="unittest.classpath." destdir="/tmp"/>
<echo file="${classpathFile2}">${classpathProp2}</echo>
<echo>unittest.classpath is written to ${classpathFile2}</echo>
</target>
<target name="instrument" depends="compile">
<taskdef name="instrument" classname="org.hibernate.tool.instrument.javassist.InstrumentTask">
<classpath refid="extended.classpath"/>
<classpath path="${classbin.dir}"/>
</taskdef>
<instrument verbose="true">
<fileset dir="${TARGETROOT}/home/WEB-INF/classes">
<include name="org/zfin/ontology/GenericTerm.class"/>
<include name="org/zfin/profile/Person.class"/>
<include name="org/zfin/expression/Figure.class"/>
<include name="org/zfin/expression/TextOnlyFigure.class"/>
<include name="org/zfin/expression/FigureFigure.class"/>
<include name="org/zfin/ontology/**Term.class"/>
<include name="org/zfin/publication/CorrespondenceComposedMessage.class"/>
<include name="org/zfin/publication/CorrespondenceSentMessage.class"/>
<include name="org/zfin/publication/Publication.class"/>
</fileset>
<fileset dir="${SOURCEROOT}/home/WEB-INF/classes">
<include name="org/zfin/ontology/GenericTerm.class"/>
<include name="org/zfin/profile/Person.class"/>
<include name="org/zfin/expression/Figure.class"/>
<include name="org/zfin/expression/TextOnlyFigure.class"/>
<include name="org/zfin/expression/FigureFigure.class"/>
<include name="org/zfin/ontology/**Term.class"/>
<include name="org/zfin/publication/CorrespondenceComposedMessage.class"/>
<include name="org/zfin/publication/CorrespondenceSentMessage.class"/>
<include name="org/zfin/publication/Publication.class"/>
</fileset>
</instrument>
</target>
<target name="compile" depends="prepare"
description="Target to compile all classes, excluding test files, and moving anything from the source
folder to the class folder.">
<!-- Delegate to Gradle for compilation (handles Lombok, annotation processing, etc.) -->
<exec executable="./gradlew" failonerror="true">
<arg value="antCompile"/>
</exec>
</target>
<target name="cleanClasses" description="Remove java classes directory contents. ">
<delete includeemptydirs="true" quiet="true">
<fileset dir="${classbin.dir}" includes="**/*"/>
<fileset dir="${lib.dir}" includes="**/*"/>
</delete>
<!--<delete includeemptydirs="true" quiet="true">-->
<!--<fileset dir="${domain-work}" includes="**/*"/>-->
<!--</delete>-->
</target>
<target name="cleanTarget" description="Remove target values. ">
<removeWebAppLocation location="${home.target}"/>
</target>
<target name="clobber" depends="cleanTarget" description="Remove target values. "/>
<target name="clean-javadoc" description="Cleans javadoc">
<delete dir="${java-doc.dir}"/>
</target>
<target name="javadocs" depends="clean-javadoc" description="Generate Javadocs into ${java-doc.dir}">
<mkdir dir="${java-doc.dir}"/>
<javadoc packagenames="org.zfin.*"
sourcepath="${source.dir}"
excludepackagenames="org.zfin.properties.*"
classpathref="combined.classpath"
destdir="${java-doc.dir}/zfin"
author="true"
version="true"
maxmemory="300m"
use="true"
private="yes"
windowtitle="ZFIN API"
doctitle="ZFIN"
bottom="Copyright © 2008 ZFIN"
locale="en"
/>
</target>
<target name="deploy-javadoc" depends="javadocs" description="Deploy the Javadoc into webroot/util/javadoc/zfin">
<mkdir dir="${TARGETROOT}/${zfin-javadoc}"/>
<copy verbose="true" todir="${TARGETROOT}/${zfin-javadoc}">
<fileset dir="${java-doc.dir}/zfin">
<include name="**/"/>
</fileset>
</copy>
</target>
<!-- ====================================================================== -->
<!-- CONFIGURATION TASKS -->
<!-- ====================================================================== -->
<target name="hibernate-available" description="Verifies that hibernate is available">
<available file="${conf.dir}/hibernate.properties" property="${hibernate.exists}"/>
</target>
<!-- ====================================================================== -->
<!-- Generate WAR. -->
<!-- ====================================================================== -->
<target name="schemaVersion" description="Prints schema version">
<java fork="yes" classname="org.zfin.database.SchemaManager" taskname="junit" failonerror="true">
<arg value="-checkSchema"/>
<classpath refid="extended.classpath"/>
</java>
</target>
<target name="prepare-properties" description="Copy jaxb properties into class hierarchy">
<copy todir="${classbin.dir}/">
<fileset dir="${source.dir}">
<include name="**/jaxb.properties"/>
<include name="**/bgm.ser"/>
</fileset>
</copy>
</target>
<target name="remove-archives" description="Removes archived builds (older than post-builds)">
<delete verbose="true" includeemptydirs="true">
<fileset dir="${TARGETROOT}/home" includes="archive*/**"/>
</delete>
</target>
<macrodef name="emailMessage">
<attribute name="message"/>
<attribute name="email"/>
<sequential>
<java classname="org.zfin.framework.mail.IntegratedJavaMailSender"
fork="yes"
classpathref="combined.classpath">
<!-- subject -->
<arg value="@{message}"/>
<!-- message -->
<arg value="@{message}"/>
<!-- email -->
<arg value="@{email}"/>
</java>
</sequential>
</macrodef>
<target name="deploy" depends="deploy-without-tests,test,productionSmokeTests"
description="Performs the full build, test, move to production, and tomcat restart appropriate for the current environment"/>
<target name="deploy-without-tests"
depends="cleanClasses,pre-deploy,build-properties,unittests-quiet,restart,deploy-solr"/>
<target name="deploy-without-tests-and-tomcat-restart"
depends="cleanClasses,pre-deploy,build-properties,unittests-quiet,deploy-solr"/>
<target name="pre-deploy" depends="do,gwt,npmInstall,npmBuild,deployGitInfoFile,gradle-tomcat-deploy"
description="Target to compile all classes (excluding jsp files) and then deploy the necessary files to user's web environment.">
<!-- <jsp-compile/> -->
</target>
<target name="dirtydeploy">
<gradle task="dirtydeploy"/>
</target>
<target name="watch">
<exec executable="./gradlew" dir="." failonerror="true">
<arg value="watch" />
<arg value="--continuous" />
</exec>
</target>
<macrodef name="removeWebAppLocation">
<attribute name="location"/>
<sequential>
<delete dir="@{location}/dist"/>
<delete dir="@{location}/fonts"/>
<delete dir="@{location}/images"/>
<delete dir="@{location}/templates"/>
<delete dir="@{location}/WEB-INF"/>
</sequential>
</macrodef>
<macrodef name="replaceProperties">
<attribute name="to"/>
<sequential>
<!--I don't think doing the full-scale delete is necessary. -->
<!--<echo message="@{to}"/>-->
<!--<delete dir="@{to}" verbose="true"/>-->
<copy todir="@{to}" verbose="false">
<fileset dir="${commons.dir}">
<include name="*.properties"/>
</fileset>
</copy>
</sequential>
</macrodef>
<target name="build-properties" description="Describes build properties for environment">
<echo>If properties are defined as true, they will show up that way, otherwise will just produce string
version.
</echo>
<echo message="Is informix: ${isinformix}"/>
<echo message="Is mutant: ${ismutant}"/>
<echo message="Not production: ${notproduction}"/>
</target>
<!--
Grand: Ant build visualization tool (JAR provided via Gradle/JitPack)
============================================
task.properties is in the grand jar: https://github.com/Ant-Grand/Grand/blob/157df7cb1505804be453c3e5ffb157267c360529/src/main/resources/task.properties
and it contains the single line:
grand=net.ggtools.grand.tasks.GrandTask
If you want to use grand, add the dependency to build.gradle:
implementation "com.github.Ant-Grand:Grand:1.9.7" // Ant build visualization tool (via JitPack)
Then uncomment the following:
<taskdef resource="task.properties" classpathref="combined.classpath"/>
<target name="graph" description="Creates graph of build process">
<grand output="build.dot" buildfile="build.xml"/>
<exec executable="dot">
<arg line="-Tps -Gsize=11.69,8.27 -Grotate=90 -o build.ps build.dot"/>
</exec>
</target>
-->
<target name="graph" description="Creates graph of build process">
<echo message="To use the 'graph' target, please add the Grand dependency to build.gradle and uncomment the relevant code in build.xml"/>
<echo message="See comments in build.xml for details."/>
</target>
<macrodef name="regenerateSSHKey">
<attribute name="ssh-command"/>
<sequential>
<delete file="@{ssh-command}"/>
<delete file="@{ssh-command}.pub"/>
<exec command="ssh-keygen">
<arg value="-f"/>
<arg value="@{ssh-command}"/>
<arg value="-t"/>
<arg value="dsa"/>
<arg value="-N"/>
<arg value=""/>
</exec>
<exec command="./buildfiles/fixKey.sh">
<arg value="@{ssh-command}"/>
</exec>
</sequential>
</macrodef>
<target name="generateSSHKeys">
<regenerateSSHKey ssh-command="cp"/>
<regenerateSSHKey ssh-command="xdget"/>
<regenerateSSHKey ssh-command="xdformat"/>
<regenerateSSHKey ssh-command="blastn"/>
<regenerateSSHKey ssh-command="blastp"/>
<regenerateSSHKey ssh-command="blastx"/>
<regenerateSSHKey ssh-command="tblastn"/>
<regenerateSSHKey ssh-command="tblastx"/>
</target>
<target name="validateDatabases" depends="compile,build-tests">
<java classname="org.zfin.sequence.blast.ValidateBlastDatabases" fork="yes"
classpathref="combined.classpath"
>
</java>
</target>
<target name="generateWebServiceClasses">
<exec executable="xjc">
<arg value="home/WEB-INF/conf/zfin.xsd"/>
<arg value="-p"/>
<arg value="org.zfin.webservice.schema"/>
<arg value="-d"/>
<arg value="source"/>
<arg value="-mark-generated"/>
</exec>
</target>
<target name="npmInstall">
<exec executable="npm" failonerror="true">
<arg value="ci"/>
</exec>
</target>
<target name="npmBuild">
<exec executable="npm" failonerror="true">
<arg value="run"/>
<arg value="build"/>
</exec>
</target>
<target name="npmLint">
<exec executable="npm" failonerror="true">
<arg value="run"/>
<arg value="lint"/>
</exec>
</target>
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpathref="combined.classpath.with.groovy"/>
<target name="deployGitInfoFile">
<gradle task="deployGitInfoFile" />
</target>
<macrodef name="gradle">
<attribute name="task" />
<sequential>
<exec executable="./gradlew" dir="." failonerror="true">
<arg value="@{task}" />
</exec>
</sequential>
</macrodef>
</project>