-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.xml
627 lines (458 loc) · 23.4 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
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
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
<!--
Ant build file for the jOAI software.
Instructions for building this software:
Prior to using this build file you must install Ant on your local system.
For information about installing and using Ant, go to http://ant.apache.org/
To build the software and deploy it into Tomcat, set up the properties shown
below and then execute the 'deploy' target (type 'ant deploy' in a command-line
environment). Details on the other ant targets can be displayed by typing
'ant -projecthelp'.
Prior to using this Ant build file, you must define the following property(s).
The property(s) may be passed into ant at the command line or placed in a
file named build.properties in your home directory or the project's root directory.
Required ant properties that must be defined:
catalina.home # The base directory of your development Tomcat 7 or 8 installation
Optional ant properties that may be defined:
oai.context.name # (Optional) The Tomcat context directory into which the software
# will be deployed. If not present, defaults to "oai"
catalina.base # (Optional) Tomcat 5.x catalina base. If not present, defaults
# to ${catalina.home}
For example, on Windows platforms your build.properties file might look like:
catalina.home = K:/username/dev/tomcat
On UNIX platforms your build.properties file might look like:
catalina.home = /home/username/dev/tomcat
Overview of Ant build files:
A "project" describes a set of targets that may be requested
when Ant is executed. The "default" attribute defines the
target which is executed if no specific target is requested,
and the "basedir" attribute defines the current working directory
from which Ant executes the requested task. This is normally
set to the current working directory.
Example commands at the your shell prompt:
> ant
# This executes the default target, in this case "compile"
> ant deploy
# This executes the "deploy" target. Since the deploy target
# is dependent on the compile target, ant will be sure the
# compile target is executed (if needed) before executing deploy.
-->
<project name="jOAI Project" default="compile" basedir=".">
<!-- ===================== Property Definitions ===========================
Each of the following properties are used in the build script.
Values for these properties are set by the first place they are
defined, from the following list:
* Definitions on the "ant" command line (ant -Dcatalina.home=xyz compile)
* Definitions from a "build.properties" file in the developer's
home directory
* Definitions from a "build.properties" file in the top level
source directory
* Default definitions in this build.xml file
You will note below that property values can be composed based on the
contents of previously defined properties. This is a powerful technique
that helps you minimize the number of changes required when your development
environment is modified. Note that property composition is allowed within
"build.properties" files as well as in the "build.xml" script.
-->
<!-- Search for properties defined in this order: -->
<property file="../joai.properties"/>
<property file="../build.properties"/>
<property file="${user.home}/joai.properties"/>
<property file="${user.home}/build.properties"/>
<property name="app.version" value="3.3"/>
<property name="app.name" value="oai"/>
<property name="oai.context.name" value="oai"/>
<property name="deploy.context.name" value="${oai.context.name}"/>
<property name="dist.deploy.name" value="${app.name}_${app.version}_dist"/>
<property name="build.home" value="build"/>
<property name="build.lib" value="web/WEB-INF/lib"/>
<property name="dist.home" value="dist"/>
<property name="junit.test.dir" value="test"/>
<property name="catalina.base" value="${catalina.home}"/>
<property name="tomcat.deploy.home" value="${catalina.base}/webapps/${deploy.context.name}"/>
<property name="dist.deploy.home" value="${catalina.base}/webapps/${dist.deploy.name}"/>
<property name="war.deploy.home" value="war-distribution"/>
<property name="javadoc.home" value="${basedir}/${build.home}/docs/javadoc"/>
<!-- Set the global Tomcat lib dir. These are at ${catalina.home}/common/lib in TC5, ${catalina.home}/lib in TC6 and later -->
<property name="catalina.lib.dir" value="${catalina.home}/lib"/>
<!-- ==================== Compilation Control Options ==================== -
These properties control option settings on the Javac compiler when it
is invoked using the <javac> task.
compile.debug Should compilation include the debug option?
compile.deprecation Should compilation include the deprecation option?
compile.optimize Should compilation include the optimize option?
-->
<property name="compile.debug" value="true"/>
<property name="compile.deprecation" value="false"/>
<property name="compile.optimize" value="true"/>
<!-- ==================== Compilation Classpath ===========================
Rather than relying on the CLASSPATH environment variable, Ant includes
features that makes it easy to dynamically construct the classpath you
need for each compilation. The example below constructs the compile
classpath to include the servlet.jar file, as well as the other components
that Tomcat makes available to web applications automatically, plus anything
that you explicitly added.
-->
<path id="compile.classpath">
<!-- Include dependent jars used in the build that are
also needed for deployment and distribution -->
<fileset dir="${build.lib}">
<include name="*.jar"/>
</fileset>
<!-- Include dependent jars used in the build that arn't
needed for deployment and distribution -->
<!--<fileset dir="build_lib">-->
<!--<include name="*.jar"/>-->
<!--</fileset>-->
<!-- Include the class dir and junit class dir so they are avail to
each other for compiling -->
<pathelement location="${build.home}/WEB-INF/classes"/>
<pathelement location="${build.home}/WEB-INF/classes-junit"/>
<!-- <pathelement location="${build.home}/WEB-INF/lib/${app.name}.jar"/> -->
<!-- Include all elements that Tomcat exposes to applications -->
<pathelement location="${catalina.home}/common/classes"/>
<pathelement location="${catalina.home}/classes"/>
<!-- Include all the global tomcat jars. These are at ${catalina.home}/common/lib in TC5, ${catalina.home}/lib in TC6 -->
<fileset dir="${catalina.lib.dir}">
<include name="*.jar"/>
</fileset>
</path>
<!-- ==================== All Target ======================================
The "all" target is a shortcut for running the "clean" target followed
by the "compile" target, to force a complete recompile.
-->
<target name="all" depends="clean,compile"
description="Clean build dir, then compile"/>
<!-- ==================== Clean Target ====================================
The "clean" target deletes any previous "build" directory,
so that you can be ensured the application can be built from scratch.
-->
<target name="clean"
description="Delete the build, dist, and junit dirs">
<delete dir="${build.home}"/>
<!--<delete dir="${dist.home}"/>-->
<delete dir="${junit.test.dir}"/>
</target>
<!-- ==================== Cleandist Target ====================================
The "cleandist" target deletes any previous "dist" directories,
so that you can be ensured the application can be built from scratch.
-->
<target name="cleandist"
description="Delete the local and tomcat dist directories">
<delete dir="${dist.home}"/>
<delete dir="${dist.deploy.home}"/>
</target>
<!-- ==================== Cleanall Target ====================================
The "cleandist" target deletes any previous "dist" directories,
so that you can be ensured the application can be built from scratch.
-->
<target name="cleanall" depends="clean,cleandist"
description="Clean the build, dist and test directories">
<!--<delete dir="${junit.test.home}"/>-->
</target>
<!-- ==================== deploy-clean Target ====================================
The "deploy-clean" target deletes any previous "deploy" directories in your
local Tomcat area.
-->
<target name="deploy-clean"
description="Delete the Tomcat deploy directory">
<delete dir="${tomcat.deploy.home}"/>
</target>
<!-- ==================== clean-tomcat-work Target ====================================
Deletes the Tomcat work files for all localhost and Standalone applications.
These files are generated and are thus expendable.
-->
<target name="clean-tomcat-work"
description="Delete the Tomcat work directory">
<delete dir="${catalina.base}/work/localhost"/>
<delete dir="${catalina.base}/work/Standalone"/>
</target>
<!-- ==================== Compile Target ==================================
The "compile" target transforms source files (from your "src" directory)
into object files in the appropriate location in the build directory.
This example assumes that you will be including your classes in an
unpacked directory hierarchy under "/WEB-INF/classes".
-->
<target name="compile" depends="prepare" description="Compile Java sources">
<echo>Compiling Java libraries</echo>
<!-- Compile Java classes as necessary -->
<mkdir dir="${build.home}/WEB-INF/classes"/>
<javac srcdir="src"
destdir="${build.home}/WEB-INF/classes"
encoding="UTF-8"
debug="${compile.debug}"
deprecation="${compile.deprecation}"
optimize="${compile.optimize}"
includeantruntime="false">
<classpath refid="compile.classpath"/>
</javac>
<!-- Copy associated resource files -->
<copy todir="${build.home}/WEB-INF/classes">
<fileset dir="src" includes="**/*.properties"/>
<fileset dir="src" includes="**/*.xml"/>
</copy>
<!-- Copy associated resource files -->
<!--<copy todir="${build.home}/WEB-INF/classes">-->
<!--<fileset dir="src" includes="**/*.properties"/>-->
<!--</copy>-->
</target>
<!-- ==================== Run JUnit Tests ==================================
Use this target to run the JUnit tests for the application and generate a report.
-->
<!-- Run unit tests... -->
<target name="unit-tests" depends="compile" description="Run JUnit tests">
<!-- make a clean directory for expendable test files -->
<delete dir="${junit.test.dir}"/>
<mkdir dir="${junit.test.dir}"/>
<junit printsummary="withOutAndErr" haltonfailure="yes" haltonerror="yes">
<!-- Make the junit test directory location available via a System prop -->
<sysproperty key="junit.test.dir" value="${basedir}/${junit.test.dir}"/>
<classpath refid="compile.classpath"/>
<formatter type="plain" usefile="false"/>
<test name="org.dlese.dpc.junit.AllToolsUnitTests"/>
</junit>
</target>
<!-- ==================== Deploy Target ===================================
The "deploy" target copies the contents of the build directory into a
location required by our servlet container, and picks up any external
dependencies along the way. After restarting the servlet container, you
can now test your web application.
-->
<target name="deploy" depends="compile, remove-obsolete-files"
description="Deploy application to servlet container">
<!-- Copy the contents of the build directory -->
<mkdir dir="${tomcat.deploy.home}"/>
<!-- Local build will have security auth turned on -->
<copy todir="${tomcat.deploy.home}/WEB-INF"
file="${build.home}/WEB-INF/web.xml">
<filterset>
<filter token="DIST-COMMENT-OPEN" value=""/>
<filter token="DIST-COMMENT-CLOSE" value=""/>
</filterset>
</copy>
<copy todir="${tomcat.deploy.home}">
<fileset dir="${build.home}"
excludes="WEB-INF/classes-junit/"/>
</copy>
</target>
<!-- Removes old JAR libraries and other files from the deployment area that may
have conflicts with newer libraries, etc. -->
<target name="remove-obsolete-files"
description="Removes files that are no longer needed in the deployment area">
<delete file="${build.home}/WEB-INF/lib/lucene-1.4.3.jar"/>
<delete file="${tomcat.deploy.home}/WEB-INF/lib/lucene-1.4.3.jar"/>
</target>
<!-- Deploy jsps, js, html, css, properties, and images, etc. directly to Tomcat for convenience -->
<target name="deploy-jsp"
description="Deploy only jsp, js, html, css, xml and image files to Tomcat">
<copy todir="${tomcat.deploy.home}" preservelastmodified="true">
<fileset dir="web">
<include name="**/*.gif"/>
<include name="**/*.jpeg"/>
<include name="**/*.jpg"/>
<include name="**/*.css"/>
<include name="**/*.js"/>
</fileset>
</copy>
<copy todir="${tomcat.deploy.home}">
<fileset dir="web">
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="**/*.txt"/>
<include name="**/*.md"/>
<include name="**/*.xml"/>
<include name="**/*.xsl"/>
</fileset>
<!-- Remove the BLANK tag in the jsps (fixes bug in JEdit if XML
declaration is the first thing in the file -->
<filterset>
<filter token="BLANK" value=""/>
</filterset>
<filterset>
<filter token="VERSION" value="${app.version}"/>
</filterset>
</copy>
<!-- Copy associated resource bundles files -->
<copy todir="${tomcat.deploy.home}/WEB-INF/classes">
<fileset dir="src" includes="**/*.properties"/>
</copy>
</target>
<!-- ==================== Dist Target =====================================
The "dist" target creates a Java WAR file distribution and a source
code distribution, packaged as ZIP files.
Note that this target depends on two others:
* "compile" so that the entire web application (including external
dependencies) will have been assembled.
* "javadoc" so that the application Javadocs will have been created
-->
<target name="dist" depends="clean,cleandist,compile,javadoc"
description="Creates a Java WAR file distribution and a source code distribution">
<!--<delete dir="${dist.deploy.home}"/>-->
<mkdir dir="${dist.deploy.home}"/>
<!-- Comment out the authentication portion, etc. -->
<copy todir="${dist.deploy.home}/WEB-INF"
file="${build.home}/WEB-INF/web.xml">
<filterset>
<filter token="DIST-COMMENT-OPEN" value="<!--"/>
<filter token="DIST-COMMENT-CLOSE" value="-->"/>
</filterset>
</copy>
<copy todir="${dist.deploy.home}">
<fileset dir="${build.home}">
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="**/*.txt"/>
<include name="**/*.md"/>
</fileset>
<!-- Remove the BLANK tag in the jsps (fixes bug in JEdit if XML
declaration is the first thing in the file -->
<filterset>
<filter token="BLANK" value=""/>
</filterset>
<filterset>
<filter token="VERSION" value="${app.version}"/>
</filterset>
</copy>
<!-- Copy the contents of the build directory -->
<copy todir="${dist.deploy.home}">
<fileset dir="${build.home}"
excludes="WEB-INF/classes-junit/"/>
</copy>
<!-- Copy in the essential docs -->
<copy todir="${dist.home}" file="COPYRIGHT.txt"/>
<copy todir="${dist.home}" file="LICENSE.txt"/>
<copy todir="${dist.home}">
<fileset dir="web/docs">
<include name="**/*.txt"/>
<include name="**/*.md"/>
</fileset>
<filterset>
<filter token="VERSION" value="${app.version}"/>
</filterset>
</copy>
<copy todir="${dist.home}/licenses">
<fileset dir="web/docs/licenses"/>
<filterset>
<filter token="VERSION" value="${app.version}"/>
</filterset>
</copy>
<!-- Create the application WAR file -->
<jar jarfile="${dist.home}/${app.name}.war"
basedir="${dist.deploy.home}"/>
<!-- Copy additional files to ${dist.home} as necessary -->
<!-- Zip the binary distribution -->
<property name="zip.name" value="joai_v${app.version}.zip"/>
<zip destfile="${basedir}/${zip.name}">
<zipfileset dir="${dist.home}" excludes="**/BUILD_INSTRUCTIONS.md" prefix="joai_v${app.version}"/>
</zip>
<move file="${basedir}/${zip.name}" tofile="${dist.home}/${zip.name}"/>
<!-- Clean out the build before zipping the code -->
<ant inheritAll="false" target="clean"/>
<!-- Zip the source code for distribution -->
<property name="src.zip.name" value="joai_v${app.version}_source.zip"/>
<zip destfile="${basedir}/../${src.zip.name}">
<zipfileset dir="${basedir}/../joai-project" excludes="${dist.home}/**" prefix="joai_v${app.version}_source/joai-project" />
<zipfileset dir="${dist.home}" includes="**/BUILD_INSTRUCTIONS.md" prefix="joai_v${app.version}_source"/>
</zip>
<move file="${basedir}/../${src.zip.name}" tofile="${dist.home}/${src.zip.name}"/>
</target>
<!-- Create an application war file suitable for deployment -->
<target name="war"
description="Creates a WAR file that can be used for internal application deployment">
<!--
Basic approach: Simply override the deploy target to deploy to the war staging dir
instead of tomcat webapps, then jar up the deployed app into a war file
-->
<echo>Creating war file for deployment</echo>
<property name="war.deploy.staging.dir" value="${war.deploy.home}/${deploy.context.name}"/>
<mkdir dir="${war.deploy.home}"/>
<ant target="clean">
<property name="tomcat.deploy.home" value="${war.deploy.staging.dir}"/>
</ant>
<ant target="deploy-clean">
<property name="tomcat.deploy.home" value="${war.deploy.staging.dir}"/>
</ant>
<ant target="javadoc">
<property name="tomcat.deploy.home" value="${war.deploy.staging.dir}"/>
</ant>
<ant target="deploy">
<property name="tomcat.deploy.home" value="${war.deploy.staging.dir}"/>
<property name="am.making.war.file" value="true"/>
</ant>
<!-- Create the application WAR file -->
<jar jarfile="${war.deploy.home}/${deploy.context.name}.war"
basedir="${war.deploy.staging.dir}"/>
</target>
<!-- ==================== Javadoc Target ==================================
The "javadoc" target creates Javadoc API documentation for the Java
classes included in your application. Normally, this is only required
when preparing a distribution release, but is available as a separate
target in case the developer wants to create Javadocs independently.
-->
<target name="javadoc" depends="compile"
description="Create Javadoc documentation">
<echo message="Building jOAI javadoc to ${javadoc.home}"/>
<mkdir dir="${javadoc.home}"/>
<javadoc sourcepath="src"
destdir="${javadoc.home}"
packagenames="*"
windowtitle="jOAI Java Documentation v${app.version}"
doctitle="jOAI Java Packages (webapp version ${app.version})"
header="jOAI Java Packages (app v${app.version})"
overview="src/overview.html">
<link href="http://docs.oracle.com/javase/8/docs/api/"/>
<link href="http://docs.oracle.com/javaee/1.4/api/"/>
<link href="http://lucene.apache.org/java/2_2_0/api/"/>
<link href="http://struts.apache.org/1.2.7/api/"/>
<link href="http://dom4j.sourceforge.net/dom4j-1.6.1/apidocs/"/>
<classpath refid="compile.classpath"/>
</javadoc>
<!-- Copy supporting files and documentation -->
<copy file="web/WEB-INF/tlds/dleseELFunctions.tld" tofile="${javadoc.home}/dleseELFunctions.xml" overwrite="yes"/>
<copy file="web/WEB-INF/tlds/dleseELFunctions.xsl" tofile="${javadoc.home}/dleseELFunctions.xsl" overwrite="yes"/>
<mkdir dir="${javadoc.home}/javadoc-includes"/>
<copy todir="${javadoc.home}/javadoc-includes" overwrite="yes">
<fileset dir="docs/javadoc-includes"/>
</copy>
</target>
<!-- ==================== Prepare Target ==================================
The "prepare" target is used to create the "build" destination directory,
and copy the static contents of your web application to it. If you need
to copy static files from external dependencies, you can customize the
contents of this task.
Normally, this task is executed indirectly when needed.
-->
<target name="prepare"
description="Prepare the build area by copying in the web and docs dirs.">
<mkdir dir="${build.home}"/>
<!-- Copy in the web dir -->
<copy todir="${build.home}">
<fileset dir="web">
<include name="**/*.jsp"/>
<include name="**/*.html"/>
<include name="**/*.txt"/>
<include name="**/*.md"/>
<include name="**/*.xml"/>
</fileset>
<!-- Remove the BLANK tag in the jsps (fixes bug in JEdit if XML
declaration is the first thing in the file -->
<filterset>
<filter token="BLANK" value=""/>
</filterset>
<filterset>
<filter token="VERSION" value="${app.version}"/>
</filterset>
</copy>
<copy todir="${build.home}">
<fileset dir="web">
<exclude name="**/*.jsp"/>
<exclude name="**/*.html"/>
<exclude name="**/*.txt"/>
<exclude name="**/*.md"/>
</fileset>
</copy>
<!-- Copy over the build.xml file -->
<copy file="build.xml" tofile="${build.home}/docs/build.txt"/>
<copy file="COPYRIGHT.txt" todir="${build.home}/docs" />
<copy file="LICENSE.txt" todir="${build.home}/docs" />
</target>
</project>