forked from marktriggs/nla-browse-handler
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbuild.xml
231 lines (213 loc) · 9.25 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
<project name="vufind-browse-handler" default="build" basedir=".">
<property name="builddir" location="build"/>
<property name="build.sysclasspath" value="last"/>
<property name="testdir" value="${builddir}/tests"/>
<property name="testoutputdir" value="${testdir}/output"/>
<property name="testdata.dir" value="tests/data"/>
<property name="authdata.dir" value="${testdata.dir}/auth"/>
<property name="bibdata.dir" value="${testdata.dir}/bib"/>
<property name="vufind.dir" value="/usr/local/vufind"/>
<property name="absolute.vufind.dir" location="${vufind.dir}"/>
<property name="solr.solr.home" value="${absolute.vufind.dir}/solr/vufind"/>
<!-- The solr.install.dir property was added to work around an issue in the Solr 9.1 test suite;
it can probably be safely removed once VuFind upgrades to Solr 9.2 or higher. -->
<property name="solr.install.dir" value="${absolute.vufind.dir}/solr/vendor"/>
<property name="java.compat.version" value="1.8"/>
<property name="ant.build.javac.source" value="1.8"/>
<property name="ant.build.javac.target" value="1.8"/>
<path id="classpath">
<pathelement location="${builddir}"/>
<fileset dir="${builddir}/deps/">
<include name="**/*.jar"/>
</fileset>
<fileset dir="tests/lib">
<include name="**/*.jar"/>
</fileset>
<!-- For Solr 8 and below: -->
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vendor/contrib/analysis-extras">
<include name="**/*.jar"/>
</fileset>
<!-- For Solr 9 and above: -->
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vendor/modules/analysis-extras">
<include name="**/*.jar"/>
</fileset>
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vendor/dist">
<include name="**/*.jar"/>
</fileset>
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vendor/server/solr-webapp/webapp/WEB-INF/lib">
<include name="**/*.jar"/>
</fileset>
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/import/lib">
<include name="**/*.jar"/>
</fileset>
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/import">
<include name="solrmarc_core_*.jar"/>
</fileset>
<!-- Needed for building tests that invoke Solr -->
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vendor/server/lib">
<include name="**/*.jar"/>
</fileset>
<!-- Pick up SQLite JDBC driver from VuFind dist-->
<fileset erroronmissingdir="false" dir="${absolute.vufind.dir}/solr/vufind/jars">
<include name="sqlite*.jar"/>
</fileset>
</path>
<!-- Can be useful for debugging -->
<!-- Must comment out before pushing, as CI environment will not have run setup before all paths are referenced -->
<!-- <pathconvert property="classpathProp" refid="classpath"/> -->
<target name="setup">
<mkdir dir="${builddir}"/>
<mkdir dir="${builddir}/deps"/>
<antcall target="setup-solr-deps"/>
</target>
<target name="setup-solr-deps">
<available file="${absolute.vufind.dir}/solr/jetty/webapps/solr.war" property="solr.war.present"/>
<antcall target="unpack-solr-war"/>
</target>
<target name="unpack-solr-war" if="solr.war.present">
<unwar src="${absolute.vufind.dir}/solr/jetty/webapps/solr.war" dest="${builddir}/deps/"/>
</target>
<target name="build" depends="clean, setup">
<!-- Can be useful for debugging -->
<!-- <pathconvert property="classpathProp" refid="classpath"/> -->
<!-- <echo>Classpath: ${classpathProp}</echo> -->
<mkdir dir="${builddir}"/>
<javac debug="on" srcdir="src/main/java" destdir="${builddir}">
<classpath refid="classpath"/>
<compilerarg value="-Xlint"/>
</javac>
<exec executable="sh" output="${builddir}/VERSION">
<arg value="-c"/>
<arg value="which git >/dev/null 2>&1 && git log --oneline -1"/>
</exec>
</target>
<target name="clean">
<delete dir="${builddir}"/>
<delete file="browse-handler.jar"/>
<delete file="browse-indexing.jar"/>
</target>
<target name="jars" depends="build">
<jar destfile="browse-handler.jar">
<fileset dir="${builddir}" includes="org/vufind/solr/handler/**/*"/>
<fileset dir="${builddir}" includes="org/vufind/util/**/*"/>
</jar>
<jar destfile="browse-indexing.jar">
<fileset dir="${builddir}" includes="org/vufind/solr/indexing/**/*"/>
<fileset dir="${builddir}" includes="org/vufind/util/**/*"/>
<!-- These files added for backwards compatibility -->
<fileset dir="${builddir}" includes="*.class"/>
<zipgroupfileset dir="${builddir}/deps/" includes="**/lucene-core*.jar"/>
</jar>
</target>
<!-- =================================
target: setup-test-cores
Put known test data into Solr cores:
start Solr,
add authority and biblographic data,
generate alphabetical indexes,
stop Solr
================================= -->
<!-- Currently working only for UNIX flavors -->
<target name="setup-test-cores"
description="Set up test Solr cores with some known test data">
<exec executable="${absolute.vufind.dir}/solr.sh">
<env key="VUFIND_HOME" value="${absolute.vufind.dir}"/>
<arg value="start"/>
</exec>
<!-- Alternately, could exec ${absolute.vufind.dir}/harvest/batch-import-marc-auth.sh -->
<apply executable="${absolute.vufind.dir}/import-marc-auth.sh">
<env key="VUFIND_HOME" value="${absolute.vufind.dir}"/>
<fileset dir="${authdata.dir}">
<include name="**/*.xml"/>
</fileset>
<!--
Would like to also use authority test records under the VuFind
test data, but they are missing the expected id fields.
-->
<!--
<fileset dir="${absolute.vufind.dir}/tests/data/authority">
<include name="**/*.mrc"/>
</fileset>
-->
</apply>
<apply executable="${absolute.vufind.dir}/import-marc.sh">
<env key="VUFIND_HOME" value="${absolute.vufind.dir}"/>
<fileset dir="${bibdata.dir}">
<include name="**/*.xml"/>
</fileset>
<fileset dir="${absolute.vufind.dir}/tests/data">
<include name="**/*.mrc"/>
</fileset>
</apply>
<exec executable="${absolute.vufind.dir}/index-alphabetic-browse.sh">
<env key="VUFIND_HOME" value="${absolute.vufind.dir}"/>
</exec>
<!-- Stop Solr so that cores unlock and unit tests can access directly -->
<exec executable="${absolute.vufind.dir}/solr.sh">
<env key="VUFIND_HOME" value="${absolute.vufind.dir}"/>
<arg value="stop"/>
</exec>
</target>
<target name="build-tests"
description="Build the test files"
depends="build">
<mkdir dir="${testdir}"/>
<javac fork="true" debug="on" srcdir="tests/" destdir="${testdir}"
classpath="tests/lib/*:${toString:classpath}:${builddir}">
<compilerarg line="-encoding UTF-8" />
</javac>
</target>
<!-- =================================
target: test-main
================================= -->
<target name="test-main"
description="Run tests, assumes build is current and test cores are set up"
depends="build-tests">
<mkdir dir="${testoutputdir}"/>
<mkdir dir="${testdir}/report"/>
<junit showoutput="yes" fork="true" haltonfailure="on">
<sysproperty key="absolute.vufind.dir" value="${absolute.vufind.dir}" />
<sysproperty key="solr.solr.home" value="${solr.solr.home}" />
<sysproperty key="solr.install.dir" value="${solr.install.dir}" />
<jvmarg value="-Dfile.encoding=UTF-8" />
<classpath>
<pathelement location="tests/lib/junit-4.11.jar"/>
<pathelement location="tests/lib/*"/>
<pathelement location="${testdir}"/>
<pathelement location="${builddir}"/>
<pathelement path="${toString:classpath}"/>
</classpath>
<!-- formatter type="plain" usefile="false"/-->
<batchtest todir="${testoutputdir}">
<fileset dir="tests">
<include name="**/*.java"/>
</fileset>
<formatter type="xml" usefile="yes"/>
<formatter type="plain" usefile="yes"/>
<formatter type="brief" usefile="no"/>
</batchtest>
</junit>
<junitreport todir="${testdir}/report">
<fileset dir="${testoutputdir}">
<include name="TEST-*.xml"/>
</fileset>
<report format="frames" todir="${testdir}/report"/>
</junitreport>
<echo message="JUnit reports available in ${testdir}/report">
</echo>
</target>
<!-- =================================
target: test
================================= -->
<target name="test" depends="build, setup-test-cores"
description="Run tests after build and setting up the test cores">
<antcall target="test-main"/>
</target>
<!-- =================================
target: test-skip-setup
================================= -->
<target name="test-skip-setup" depends="build"
description="Run tests after build, assumes test cores are already set up">
<antcall target="test-main"/>
</target>
</project>