/
build.xml
1188 lines (932 loc) · 46 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
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?xml version="1.0"?>
<!--
The contents of this file are subject to the license and copyright
detailed in the LICENSE and NOTICE files at the root of the source
tree and available online at
http://www.dspace.org/license/
-->
<!--
- DSpace build file
-
- Version: $Revision$
- Date: $Date$
-->
<project name="DSpace" default="help">
<!-- ============================================================= -->
<!-- Description -->
<!-- ============================================================= -->
<description>
====================== DSpace platform build file ======================
Common usage:
Fresh install of DSpace:
% ant fresh_install
Update existing installation, leaving data and configuration intact:
% ant -Dconfig=/installdir/config/dspace.cfg update
========================================================================
</description>
<!-- DS-1391: Ant 1.8.0+ is required, fail if not available. -->
<fail message="Ant 1.8.0+ is required, ${ant.version} is not supported">
<condition>
<not>
<antversion atleast="1.8.0"/>
</not>
</condition>
</fail>
<!-- ============================================================= -->
<!-- Will be using various environment variables -->
<!-- ============================================================= -->
<property environment="env" />
<!-- ============================================================= -->
<!-- Build parameters that are likely to need tweaking -->
<!-- ============================================================= -->
<!-- Default overwrite to true. This may be overridden. -->
<condition property="overwrite" value="true">
<not>
<isset property="overwrite"/>
</not>
</condition>
<!-- Default configuration to use. This may be overridden. -->
<property name="config" value="config/dspace.cfg" />
<!-- Give user a chance to override without editing this file
(and without typing -D each time s/he compiles it) -->
<property file="${user.home}/.dspace.properties" />
<!-- First, set the dspace.dir property so it can be
interpolated when loading the config file.
This crudely mimics the way ConfigurationManager interpolates properties.
Note that it ONLY works for directories that interpolate ${dspace.dir}
but that _should_ cover all cases used in this build configuration.
-->
<loadproperties srcFile="${config}">
<filterchain>
<linecontainsregexp>
<regexp pattern="^\s*dspace\.dir\s+" />
</linecontainsregexp>
</filterchain>
</loadproperties>
<!-- Load the configuration -->
<property file="${config}" />
<!-- Timestamp date used when creating backup directories -->
<tstamp>
<format property="build.date" pattern="yyyyMMdd-HHmmss" />
</tstamp>
<!-- Default location of GeoLiteCity.dat.gz to download. This may be overridden, if URL path changes. -->
<property name="geolite" value="http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz" />
<!-- Default location of lucene-core JAR to download (for update_solr_indexes). This may be overridden, if URL path changes. -->
<!-- NOTE: this URL should have the version of the JAR replaced with "[version]" -->
<property name="lucene-core" value="http://search.maven.org/remotecontent?filepath=org/apache/lucene/lucene-core/[version]/lucene-core-[version].jar" />
<!-- ============================================================= -->
<!-- The DSpace class path for executing installation targets -->
<!-- ============================================================= -->
<!-- We will include the environment CLASSPATH -->
<path id="class.path">
<pathelement path="${env.CLASSPATH}" />
<fileset dir="lib">
<include name="**/*.jar" />
</fileset>
</path>
<!-- ============================================================= -->
<!-- Load various Ant libraries which define extra tasks. -->
<!-- ============================================================= -->
<!--Load/initialize all Ant-Contrib libraries from DSpace 'class.path' above.
For more info, see:
http://ant-contrib.sourceforge.net/tasks/index.html -->
<taskdef resource="net/sf/antcontrib/antlib.xml" classpathref="class.path"/>
<!-- ============================================================= -->
<!-- Print some useful help text -->
<!-- ============================================================= -->
<target name="help">
<echo message="" />
<echo message="DSpace configuration file" />
<echo message="-----------------------------------" />
<echo message="" />
<echo message="Available targets are:" />
<echo message="" />
<echo message="update --> Update ${dspace.dir} config, etc, lib and web applications without " />
<echo message=" touching your data" />
<echo message="update_configs --> Update your configs directory with new configuration files"/>
<echo message="update_geolite --> Dowload and install GeoCity database into ${dspace.dir}/config" />
<echo message="update_code --> Update compiled code (bin, lib, and etc directories)" />
<echo message="update_webapps --> Update web applications" />
<echo message="update_solr_indexes --> Checks if any Solr indexes need upgrading (to latest Solr), and if so, upgrades them." />
<echo message="" />
<echo message="init_configs --> Write the configuration files to ${dspace.dir}/config" />
<echo message="install_code --> Install compiled code into ${dspace.dir}" />
<echo message="" />
<echo message="fresh_install --> Perform a fresh installation of the software. " />
<echo message="" />
<echo message="clean_backups --> Remove .bak directories under install directory" />
<echo message="migrate_database --> Migrate the DSpace database to the latest version." />
<echo message="" />
<echo message="" />
<echo message="Available parameters are:" />
<echo message="" />
<echo message="-Dconfig=<path/to/dspace.cfg> -- Where your dspace.cfg configuration" />
<echo message=" is located" />
<echo message="-Doverwrite=false -- Will force update_configs to no longer copy existing"/>
<echo message=" config to .old files when they conflict with"/>
<echo message=" the new config. Instead, new conflicting"/>
<echo message=" file with be suffixed with .new."/>
<echo message="-Dwars=true -- Build .war files when updating web" />
<echo message=" applications" />
<echo message="" />
</target>
<!-- ============================================================= -->
<!-- clean out backup directories -->
<!-- ============================================================= -->
<target name="clean_backups">
<delete includeemptydirs="true">
<fileset dir="${dspace.dir}" includes="lib.bak-**/**" />
</delete>
<delete includeemptydirs="true">
<fileset dir="${dspace.dir}" includes="etc.bak-**/**" />
</delete>
<delete includeemptydirs="true">
<fileset dir="${dspace.dir}" includes="webapps.bak-**/**" />
</delete>
<delete includeemptydirs="true">
<fileset dir="${dspace.dir}" includes="bin.bak-**/**" />
</delete>
</target>
<!-- ============================================================= -->
<!-- Update an installation -->
<!-- ============================================================= -->
<target name="update" depends="update_configs,update_code,migrate_database,update_webapps,update_solr_indexes" description="Update installed code and web applications (without clobbering data/config)">
</target>
<!-- ============================================================= -->
<!-- Update the config dir, only adds files, if a file is altered -->
<!-- in the target directory, the new file is suffixed wth *.new -->
<!-- and should be hand updated afterward . -->
<!-- ============================================================= -->
<target name="update_configs" depends="overwrite_configs,overwrite_solr_configs" description="Updates the Configuration Directory">
<antcall target="init_geolite" />
</target>
<target name="overwrite_configs" description="Overwrites a configuration directory." if="${overwrite}" depends="copy_configs_keep">
<!--
Copy files that are absent in target
-->
<copy todir="${dspace.dir}/config" preservelastmodified="true">
<fileset dir="config-temp" includes="**/*">
<present present="srconly" targetdir="${dspace.dir}/config" />
</fileset>
</copy>
<!--
Copy files that are different in target to *.old suffix
-->
<copy todir="${dspace.dir}/config" preservelastmodified="true" overwrite="true">
<fileset dir="${dspace.dir}/config">
<and>
<different targetdir="config-temp" ignoreFileTimes="true" />
<present present="both" targetdir="config-temp" />
</and>
<type type="file" />
</fileset>
<globmapper from="*" to="*-${build.date}.old" />
</copy>
<!--
Force overwrite of whats left
-->
<copy todir="${dspace.dir}/config" preservelastmodified="true" overwrite="true">
<fileset dir="config-temp">
<different targetdir="${dspace.dir}/config" ignoreFileTimes="true" />
<type type="file" />
</fileset>
</copy>
<!--
Remove the work directory
-->
<delete dir="config-temp" />
<echo>
====================================================================
The DSpace configuration has been updated.
During the upgrade process the build has attempted to overwrite the
previous configuration while preserving your previous changes in files
suffixed "*.old"
To complete installation, you should do the following:
* Check that you've properly merged any differences in the following files:
</echo>
<fileset dir="${dspace.dir}/config" id="config.files">
<include name="**/*.old"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="configfiles" refid="config.files"/>
<echo>${configfiles}</echo>
<echo>
* To properly merge your previous configuration files, it's
best to try to take the newer version and copy your
previous changes into it.
====================================================================
</echo>
</target>
<target name="copy_configs_keep" unless="${overwrite}" depends="prepare_configs">
<!--
Copy files that are absent in target
-->
<copy todir="${dspace.dir}/config" preservelastmodified="true">
<fileset dir="config-temp" includes="**/*">
<present present="srconly" targetdir="${dspace.dir}/config" />
</fileset>
</copy>
<!--
Copy files that are different to target to *.new suffix
-->
<copy todir="${dspace.dir}/config" preservelastmodified="true">
<fileset dir="config-temp">
<different targetdir="${dspace.dir}/config" ignoreFileTimes="true" />
<type type="file" />
</fileset>
<globmapper from="*" to="*.new" />
</copy>
<!--
Remove the work directory
-->
<delete dir="config-temp" />
<echo>
====================================================================
The DSpace configuration has been updated.
During the upgrade process the build has preserved your original
configuration and placed any conflicting new files next to your
original suffixed with the "*.new" extension.
To complete installation, you should do the following:
* Check that you've properly merged any differences in the following files:
</echo>
<fileset dir="${dspace.dir}/config" id="config.files">
<include name="**/*.new"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="configfiles" refid="config.files"/>
<echo>${configfiles}</echo>
<echo>
* To properly merge your previous configuration files, it's
best to try to take the newer version and copy your
previous changes into it. Delete the old and remove the
".new" suffix from the new file.
====================================================================
</echo>
</target>
<target name="prepare_configs" description="Updates a configuration directory.">
<mkdir dir="config-temp" />
<!--
Copy designated dspace.cfg
-->
<copy file="${config}" tofile="config-temp/dspace.cfg" preservelastmodified="true" />
<!--
If designated config isn't the one in config/dspace.cfg then lets put a copy of that next to it
-->
<copy todir="config-temp" preservelastmodified="true" overwrite="true" >
<fileset dir="config" includes="dspace.cfg">
<different targetdir="${dspace.dir}/config" ignoreFileTimes="true" />
</fileset>
<globmapper from="*" to="*.default" />
</copy>
<!--
Prepare properly filtered files
-->
<copy todir="config-temp" preservelastmodified="true" overwrite="true" failonerror="false">
<fileset dir="config" excludes="dspace.cfg" />
<filterchain>
<expandproperties />
</filterchain>
</copy>
<echo file='config-temp/ant.properties' message='ant.version = ${ant.version}'/>
</target>
<target name="overwrite_solr_configs" description="Overwrites a configuration directory." if="${overwrite}" depends="copy_solr_configs_keep">
<!--
Copy files that are absent in target
-->
<copy todir="${dspace.dir}/solr" preservelastmodified="true">
<fileset dir="solr-config-temp" includes="**/*">
<and>
<present present="srconly" targetdir="${dspace.dir}/solr" />
<!-- acts like <exclude name="**/data/**"/> -->
<filename negate="true" name="**/data/**"/>
</and>
</fileset>
</copy>
<!--
Copy files that are different in target to *.old suffix
-->
<copy todir="${dspace.dir}/solr" preservelastmodified="true" overwrite="true">
<fileset dir="${dspace.dir}/solr">
<and>
<different targetdir="solr-config-temp" ignoreFileTimes="true" />
<present present="both" targetdir="solr-config-temp" />
<!-- acts like <exclude name="**/data/**"/> -->
<filename negate="true" name="**/data/**"/>
</and>
<type type="file" />
</fileset>
<globmapper from="*" to="*-${build.date}.old" />
</copy>
<!--
Force overwrite of whats left
-->
<copy todir="${dspace.dir}/solr" preservelastmodified="true" overwrite="true">
<fileset dir="solr-config-temp">
<and>
<different targetdir="${dspace.dir}/solr" ignoreFileTimes="true" />
<!-- acts like <exclude name="**/data/**"/> -->
<filename negate="true" name="**/data/**"/>
</and>
<type type="file" />
</fileset>
</copy>
<!--
Remove the work directory
-->
<delete dir="solr-config-temp" />
<echo>
====================================================================
The DSpace configuration has been updated.
During the upgrade process the build has attempted to overwrite the
previous configuration while preserving your previous changes in files
suffixed "*.old"
To complete installation, you should do the following:
* Check that you've properly merged any differences in the following files:
</echo>
<fileset dir="${dspace.dir}/solr" id="config.files">
<include name="**/*.old"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="configfiles" refid="config.files"/>
<echo>${configfiles}</echo>
<echo>
* To properly merge your previous configuration files, it's
best to try to take the newer version and copy your
previous changes into it.
====================================================================
</echo>
</target>
<target name="copy_solr_configs_keep" unless="${overwrite}" depends="prepare_solr_configs">
<!--
Copy files that are absent in target
-->
<copy todir="${dspace.dir}/solr" preservelastmodified="true">
<fileset dir="solr-config-temp" includes="**/*">
<and>
<present present="srconly" targetdir="${dspace.dir}/solr"/>
<!-- acts like <exclude name="**/data/**"/> -->
<filename negate="true" name="**/data/**"/>
</and>
</fileset>
</copy>
<!--
Copy files that are different to target to *.new suffix
-->
<copy todir="${dspace.dir}/solr" preservelastmodified="true">
<fileset dir="solr-config-temp">
<and>
<different targetdir="${dspace.dir}/solr" ignoreFileTimes="true"/>
<!-- acts like <exclude name="**/data/**"/> -->
<filename negate="true" name="**/data/**"/>
</and>
<type type="file" />
</fileset>
<globmapper from="*" to="*.new" />
</copy>
<!--
Remove the work directory
-->
<delete dir="solr-config-temp" />
<echo>
====================================================================
The DSpace configuration has been updated.
During the upgrade process the build has preserved your original
configuration and placed any conflicting new files next to your
original suffixed with the "*.new" extension.
To complete installation, you should do the following:
* Check that you've properly merged any differences in the following files:
</echo>
<fileset dir="${dspace.dir}/solr" id="config.files">
<include name="**/*.new"/>
</fileset>
<pathconvert pathsep="${line.separator}" property="configfiles" refid="config.files"/>
<echo>${configfiles}</echo>
<echo>
* To properly merge your previous configuration files, it's
best to try to take the newer version and copy your
previous changes into it. Delete the old and remove the
".new" suffix from the new file.
====================================================================
</echo>
</target>
<target name="prepare_solr_configs" description="Prepares solr configuration directory.">
<mkdir dir="solr-config-temp" />
<!--
Prepare properly filtered files
-->
<copy todir="solr-config-temp" preservelastmodified="true" overwrite="true" failonerror="false">
<fileset dir="solr">
<!-- exclude all "data" directories from being overwritten -->
<exclude name="**/data/**"/>
</fileset>
<filterchain>
<expandproperties />
</filterchain>
</copy>
</target>
<!-- ============================================================= -->
<!-- Update core code only (no webapps or configs) -->
<!-- ============================================================= -->
<target name="update_code" description="Update installed code (without clobbering data/config)">
<move todir="${dspace.dir}/bin.bak-${build.date}" failonerror="no">
<fileset dir="${dspace.dir}/bin">
<include name="**/*" />
</fileset>
</move>
<copy todir="${dspace.dir}/bin" preservelastmodified="true">
<fileset dir="bin" />
</copy>
<chmod dir="${dspace.dir}/bin" perm="u+x" includes="**/*" />
<move todir="${dspace.dir}/lib.bak-${build.date}" failonerror="no">
<fileset dir="${dspace.dir}/lib">
<include name="**/*" />
</fileset>
</move>
<copy todir="${dspace.dir}/lib" preservelastmodified="true">
<fileset dir="lib" />
</copy>
<move todir="${dspace.dir}/etc.bak-${build.date}" failonerror="no">
<fileset dir="${dspace.dir}/etc">
<include name="**/*" />
</fileset>
</move>
<copy todir="${dspace.dir}/etc" preservelastmodified="true">
<fileset dir="etc" />
</copy>
<copy todir="${dspace.dir}/solr" preservelastmodified="true">
<fileset dir="solr"/>
</copy>
<echo>
====================================================================
${dspace.dir}/bin was backed up to
${dspace.dir}/bin.bak-${build.date}
${dspace.dir}/lib was backed up to
${dspace.dir}/lib.bak-${build.date}
${dspace.dir}/etc was backed up to
${dspace.dir}/etc.bak-${build.date}
Please review these directories and delete if no longer needed.
====================================================================
</echo>
</target>
<!-- ============================================================= -->
<!-- Update Web Applications only -->
<!-- ============================================================= -->
<target name="update_webapps" description="Update Web Applications (without clobbering data/config)">
<move todir="${dspace.dir}/webapps.bak-${build.date}" failonerror="no">
<fileset dir="${dspace.dir}/webapps">
<include name="**/*" />
</fileset>
</move>
<echo>
====================================================================
${dspace.dir}/webapps was backed up to
${dspace.dir}/webapps.bak-${build.date}
Please review this directory and delete it if it's no longer needed.
====================================================================
</echo>
<antcall target="copy_webapps" />
<echo>
====================================================================
Updated DSpace Web application directories are in the
'${dspace.dir}/webapps' directory.
* Stop your Web servlet container (Tomcat, Jetty, Resin etc.)
* If your Web servlet container already loads the DSpace
UI web applications from ${dspace.dir}/webapps/, then you
can jump straight to restarting your Web servlet container
* Otherwise, you will need to copy any web applications from
${dspace.dir}/webapps/ to the appropriate place for your servlet
container. (e.g. '$CATALINA_HOME/webapps' for Tomcat)
If you're using Tomcat, you should first delete any existing
DSpace directories in '$CATALINA_HOME/webapps/' (e.g. you would
delete an existing $CATALINA_HOME/webapps/dspace/ directory).
Otherwise, Tomcat may continue to use old code in that directory.
* Start up your Web servlet container again.
====================================================================
</echo>
</target>
<!-- ============================================================= -->
<!-- Copy Web Applications to Runtime Location -->
<!-- ============================================================= -->
<target name="copy_webapps">
<!-- Copy webapp files to /webapps (excluding any filtered files) -->
<copy todir="${dspace.dir}/webapps" preservelastmodified="true" failonerror="no">
<fileset dir="webapps">
<exclude name="**/web.xml" />
<exclude name="**/robots.txt" />
</fileset>
</copy>
<!-- Ensure specific webapp files (web.xml, robots.txt) are filtered -->
<copy todir="${dspace.dir}/webapps" preservelastmodified="false" failonerror="no">
<fileset dir="webapps">
<include name="**/web.xml" />
<include name="**/robots.txt" />
</fileset>
<filterchain>
<expandproperties />
</filterchain>
</copy>
<antcall target="build_webapps_wars"/>
</target>
<!-- ============================================================= -->
<!-- Compress Web Applications -->
<!-- (Only executes if the "wars" property is defined) -->
<!-- ============================================================= -->
<target name="build_webapps_wars" description="Compress Web Applications into .war files" if="wars">
<war destfile="${dspace.dir}/webapps/xmlui.war">
<fileset dir="${dspace.dir}/webapps/xmlui/" />
</war>
<war destfile="${dspace.dir}/webapps/oai.war">
<fileset dir="${dspace.dir}/webapps/oai/" />
</war>
<war destfile="${dspace.dir}/webapps/jspui.war">
<fileset dir="${dspace.dir}/webapps/jspui/" />
</war>
<war destfile="${dspace.dir}/webapps/rdf.war">
<fileset dir="${dspace.dir}/webapps/rdf/"/>
</war>
<war destfile="${dspace.dir}/webapps/rest.war">
<fileset dir="${dspace.dir}/webapps/rest/"/>
</war>
<war destfile="${dspace.dir}/webapps/sword.war">
<fileset dir="${dspace.dir}/webapps/sword/" />
</war>
<war destfile="${dspace.dir}/webapps/solr.war">
<fileset dir="${dspace.dir}/webapps/solr/" />
</war>
</target>
<!-- ============================================================= -->
<!-- Install DSpace and Dependencies -->
<!-- ============================================================= -->
<target name="init_installation">
<mkdir dir="${dspace.dir}/bin" />
<mkdir dir="${dspace.dir}/config" />
<mkdir dir="${dspace.dir}/lib" />
<mkdir dir="${dspace.dir}/etc" />
<mkdir dir="${dspace.dir}/webapps" />
<mkdir dir="${dspace.dir}/triplestore" />
<mkdir dir="${org.dspace.app.itemexport.work.dir}" />
<mkdir dir="${org.dspace.app.itemexport.download.dir}" />
<mkdir dir="${assetstore.dir}" />
<mkdir dir="${handle.dir}" />
<mkdir dir="${log.dir}" />
<mkdir dir="${upload.temp.dir}" />
<mkdir dir="${report.dir}" />
<mkdir dir="${dspace.dir}/solr" />
<!-- Runtime files (Could be erased - just for performing purposes) -->
<mkdir dir="${dspace.dir}/var" />
<!-- Runtime files for OAI 2.0 -->
<mkdir dir="${dspace.dir}/var/oai" />
</target>
<!-- ============================================================= -->
<!-- Fresh install of config files -->
<!-- ============================================================= -->
<!-- Writes the configuration files to ${dspace.dir}/config. It does *not*
run the install-configs script. The "log4j.build.properties" file is
copied to ${dspace.dir}/config so there's a simple log4j.properties
file present for the initial run of "install-configs". -->
<target name="init_configs" depends="init_installation">
<copy todir="${dspace.dir}/config" preservelastmodified="true" failonerror="false">
<fileset dir="config" excludes="dspace.cfg" />
<filterchain>
<expandproperties />
</filterchain>
</copy>
<copy file="${config}" tofile="${dspace.dir}/config/dspace.cfg" preservelastmodified="true" />
<echo file='${dspace.dir}/config/ant.properties' message='ant.version = ${ant.version}'/>
</target>
<!-- ============================================================= -->
<!-- Check the connection to the database -->
<!-- ============================================================= -->
<!-- Test the connection to the database -->
<target name="test_database">
<java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes">
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
<sysproperty key="dspace.log.init.disable" value="true" />
<sysproperty key="dspace.configuration" value="${config}" />
<arg value="database" />
<arg value="test" />
</java>
</target>
<!-- Migrate the database -->
<target name="migrate_database">
<java classname="org.dspace.app.launcher.ScriptLauncher" classpathref="class.path" fork="yes" failonerror="yes">
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
<sysproperty key="dspace.log.init.disable" value="true" />
<sysproperty key="dspace.configuration" value="${config}" />
<arg value="database" />
<arg value="migrate" />
</java>
</target>
<!-- ============================================================= -->
<!-- Install fresh code but do not touch the database -->
<!-- ============================================================= -->
<target name="install_code"
depends="init_installation,init_configs"
description="Do a fresh install of the code, preserving any data."
>
<delete failonerror="no">
<fileset dir="${dspace.dir}/bin" includes="**/*" />
</delete>
<copy todir="${dspace.dir}/bin" preservelastmodified="true">
<fileset dir="bin" />
</copy>
<chmod dir="${dspace.dir}/bin" perm="u+x" includes="**/*" />
<delete failonerror="no">
<fileset dir="${dspace.dir}/lib" includes="**/*" />
</delete>
<copy todir="${dspace.dir}/lib" preservelastmodified="true">
<fileset dir="lib" />
</copy>
<!-- NB: no regular use is made of etc/ files in an installed
- system, so this step is 'deprecated', and will eventually
- be removed. -->
<delete failonerror="no">
<fileset dir="${dspace.dir}/etc" includes="**/*" />
</delete>
<copy todir="${dspace.dir}/etc" preservelastmodified="true">
<fileset dir="etc" />
</copy>
<copy todir="${dspace.dir}/solr" preservelastmodified="true">
<fileset dir="solr" />
</copy>
<echo>
====================================================================
The DSpace code has been installed.
====================================================================
</echo>
</target>
<!-- ============================================================= -->
<!-- Do a fresh system install -->
<!-- ============================================================= -->
<target name="fresh_install"
depends="init_installation,init_configs,test_database,install_code,migrate_database"
description="Do a fresh install of the system, overwriting any data">
<delete failonerror="no">
<fileset dir="${dspace.dir}/webapps" includes="**/*" />
</delete>
<antcall target="copy_webapps" />
<antcall target="init_geolite" />
<echo>
====================================================================
The DSpace code has been installed.
To complete installation, you should do the following:
* Setup your Web servlet container (e.g. Tomcat) to look for your
DSpace web applications in: ${dspace.dir}/webapps/
OR, copy any web applications from ${dspace.dir}/webapps/ to
the appropriate place for your servlet container.
(e.g. '$CATALINA_HOME/webapps' for Tomcat)
* Start up your servlet container (e.g. Tomcat). DSpace now will
initialize the database on the first startup.
* Make an initial administrator account (an e-person) in DSpace:
${dspace.dir}/bin/dspace create-administrator
You should then be able to access your DSpace's 'home page':
${dspace.url}
====================================================================
</echo>
</target>
<!-- installs GeoCity resolution database -->
<target name="update_geolite">
<echo>Downloading: ${geolite}</echo>
<trycatch property="geolite.error">
<try>
<get src="${geolite}" dest="${dspace.dir}/config/GeoLiteCity.dat.gz" verbose="true"/>
<gunzip src="${dspace.dir}/config/GeoLiteCity.dat.gz" dest="${dspace.dir}/config/GeoLiteCity.dat" />
<delete file="${dspace.dir}/config/GeoLiteCity.dat.gz" />
</try>
<catch>
<echo>
====================================================================
WARNING : FAILED TO DOWNLOAD GEOLITE DATABASE FILE
(Used for DSpace Solr Usage Statistics)
Underlying Error: ${geolite.error}
In order to use DSpace Solr Usage Statistics, you will need to
manually re-run:
ant update_geolite
OR
You may manually install this file by following these steps:
(1) Download the file from ${geolite}
(2) Unzip it to create a file named 'GeoLiteCity.dat'
(3) Copy that file to '${dspace.dir}/config/GeoLiteCity.dat'
====================================================================
</echo>
</catch>
</trycatch>
</target>
<target name="check_geolite">
<condition property="need.geolite">
<not>
<available file="${dspace.dir}/config/GeoLiteCity.dat" />
</not>
</condition>
</target>
<target name="init_geolite" depends="check_geolite" if="need.geolite">
<antcall target="update_geolite" />
</target>
<!-- Check if any Solr indexes need updating to the version of Solr/Lucene we are using. -->
<target name="update_solr_indexes">
<echo>Checking if any Solr indexes (${dspace.dir}/solr/*) need upgrading...</echo>
<!--
For each index, this is currently a two step process:
(1) Ensure the index is upgraded to Solr/Lucene 3.5.0
(really old indexes need upgrading to this version first)
(2) Then, we can upgrade from 3.5.0 to latest version of Lucene
-->
<!-- Determine what version of Solr/Lucene is being used in DSpace. -->
<java classname="org.dspace.app.util.IndexVersion" classpathref="class.path" fork="yes" outputproperty="latest_version">
<sysproperty key="log4j.configuration" value="file:config/log4j-console.properties" />
<sysproperty key="dspace.log.init.disable" value="true" />
<arg value="-v" />
</java>
<echo>Current version of Solr/Lucene: ${latest_version}</echo>
<!-- First, let's do the Solr Statistics index -->
<property name="stats.index" value="${dspace.dir}/solr/statistics/data/index/"/>
<if>
<available file="${stats.index}" type="dir"/>
<then>
<!-- Ensure Statistics index is >= Solr/Lucene 3.5.0 -->
<antcall target="check_solr_index">
<param name="indexDir" value="${stats.index}"/>
<param name="version" value="3.5.0"/>
<param name="included" value="false"/>
</antcall>
<!-- Ensure Statistics index is upgraded to latest version (included in DSpace) -->
<antcall target="check_solr_index">
<param name="indexDir" value="${stats.index}"/>
<param name="version" value="${latest_version}"/>
<param name="included" value="true"/>
</antcall>
</then>
</if>
<!-- Next, let's do the Discovery Solr index.
NOTE: Discovery will be reindexed post database migration, but this
is here as a safety measure for older versions of Solr/Lucene -->
<property name="discovery.index" value="${dspace.dir}/solr/search/data/index/"/>
<if>
<available file="${discovery.index}" type="dir"/>
<then>
<!-- Ensure Discovery index is >= Solr/Lucene 3.5.0 -->