1 | <?xml version="1.0"?>
|
---|
2 | <project name="gs3-solr-ext" default="usage" basedir=".">
|
---|
3 |
|
---|
4 | <!-- DIRECTORY LOCATIONS -->
|
---|
5 | <!-- local ext paths -->
|
---|
6 | <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
|
---|
7 | <property name="src.home" value="${basedir}/src/java"/>
|
---|
8 | <property name="build.home" value="${basedir}/build"/>
|
---|
9 | <available property="ext.web.exists" file="${basedir}/web" type="dir" />
|
---|
10 |
|
---|
11 | <!-- greenstone3 paths -->
|
---|
12 | <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
|
---|
13 | http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
|
---|
14 | <property name="web.home" location="${basedir}/../../web"/> <!-- location property creates an absolute path -->
|
---|
15 | <property name="localsite.collectdir" value="${web.home}/sites/localsite/collect"/>
|
---|
16 | <property name="web.classesdir" value="${web.home}/WEB-INF/classes"/>
|
---|
17 | <property name="web.libdir" value="${web.home}/WEB-INF/lib"/>
|
---|
18 | <property name="web.extdir" value="${web.home}/ext/solr"/>
|
---|
19 |
|
---|
20 | <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
|
---|
21 | <and>
|
---|
22 | <isset property="gs3.tomcat.installed.path"/>
|
---|
23 | <not>
|
---|
24 | <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
|
---|
25 | </not>
|
---|
26 | </and>
|
---|
27 | </condition>
|
---|
28 | <condition property="solr.context" value="${gs3.solr.context}" else="solr">
|
---|
29 | <and>
|
---|
30 | <isset property="gs3.solr.context"/>
|
---|
31 | <not>
|
---|
32 | <equals arg1="${gs3.solr.context}" arg2=""/>
|
---|
33 | </not>
|
---|
34 | </and>
|
---|
35 | </condition>
|
---|
36 | <property name="tomcat.lib.dir" value="${tomcat.dir}/lib"/>
|
---|
37 | <property name="tomcat.context.dir" value="${tomcat.dir}/conf/Catalina/localhost"/>
|
---|
38 |
|
---|
39 |
|
---|
40 | <path id="compile.classpath">
|
---|
41 | <!-- gs3 jar files we need -->
|
---|
42 | <pathelement location="${web.libdir}/gsdl3.jar"/>
|
---|
43 | <pathelement location="${web.libdir}/gutil.jar"/>
|
---|
44 | <pathelement location="${web.libdir}/LuceneWrapper4.jar"/>
|
---|
45 | <pathelement location="${web.libdir}/gson-1.7.1.jar"/>
|
---|
46 | <!-- local jar files -->
|
---|
47 | <fileset dir="lib/java">
|
---|
48 | <include name="*.jar"/>
|
---|
49 | </fileset>
|
---|
50 | <pathelement location="lib/servlet-api-3.0.jar"/>
|
---|
51 | </path>
|
---|
52 |
|
---|
53 |
|
---|
54 | <!-- FILE LISTINGS.-->
|
---|
55 | <!-- Created as property elements rather than as filelist elements, since
|
---|
56 | they can then be reused for the add-service and delete-service targets. -->
|
---|
57 | <property name="jars"
|
---|
58 | value="solr-core-4.7.2.jar
|
---|
59 | solr-solrj-4.7.2.jar
|
---|
60 | lucene-core-4.7.2.jar
|
---|
61 | lucene-analyzers-common-4.7.2.jar
|
---|
62 | lucene-analyzers-kuromoji-4.7.2.jar
|
---|
63 | lucene-analyzers-phonetic-4.7.2.jar
|
---|
64 | lucene-grouping-4.7.2.jar
|
---|
65 | lucene-highlighter-4.7.2.jar
|
---|
66 | lucene-queries-4.7.2.jar
|
---|
67 | lucene-queryparser-4.7.2.jar
|
---|
68 | lucene-memory-4.7.2.jar
|
---|
69 | lucene-misc-4.7.2.jar
|
---|
70 | lucene-spatial-4.7.2.jar
|
---|
71 | lucene-suggest-4.7.2.jar
|
---|
72 | httpclient-4.3.1.jar
|
---|
73 | httpcore-4.3.jar
|
---|
74 | httpmime-4.3.1.jar
|
---|
75 | commons-fileupload-1.2.1.jar
|
---|
76 | commons-io-2.1.jar
|
---|
77 | commons-lang-2.6.jar
|
---|
78 | velocity-1.6.1.jar
|
---|
79 | log4j-over-slf4j-1.6.6.jar
|
---|
80 | slf4j-api-1.6.6.jar
|
---|
81 | slf4j-jdk14-1.6.6.jar
|
---|
82 | spatial4j-0.4.1.jar
|
---|
83 | zookeeper-3.4.5.jar
|
---|
84 | guava-14.0.1.jar
|
---|
85 | noggit-0.5.jar"/>
|
---|
86 | <!-- jcl-over-slf4j-1.6.6.jar
|
---|
87 | jul-to-slf4j-1.6.6.jar
|
---|
88 | log4j-1.2.16.jar
|
---|
89 | wstx-asl-3.2.7.jar
|
---|
90 | -->
|
---|
91 | <!--
|
---|
92 | lucene-spellchecker-3.3.0.jar replaced with lucene-suggest-4.7.2.jar, since both contain packages org/.../spell and org/.../suggest
|
---|
93 |
|
---|
94 | commons-fileupload-1.2.1.jar - in solr war file
|
---|
95 | velocity-1.6.1.jar
|
---|
96 | log4j-over-slf4j-1.6.1.jar - have to download slf4j jar file for version 1.6.6
|
---|
97 | slf4j-jdk14-1.6.1.jar - have to download slf4j jar file for version 1.6.6
|
---|
98 | -->
|
---|
99 |
|
---|
100 | <property name="shared-xalan-jars"
|
---|
101 | value="xalan.jar
|
---|
102 | xercesImpl.jar
|
---|
103 | xml-apis.jar
|
---|
104 | xsltc.jar
|
---|
105 | serializer.jar"/>
|
---|
106 | <property name="russian-morph-jars"
|
---|
107 | value="jmorphy2-lucene-0.2.0.jar
|
---|
108 | jmorphy2-nlp-0.2.0.jar
|
---|
109 | jmorphy2-core-0.2.0.jar
|
---|
110 | dawg-0.2.0.jar
|
---|
111 | jmorphy2-dicts-uk-0.2.0.jar
|
---|
112 | guava-18.0.jar
|
---|
113 | commons-codec-1.10.jar
|
---|
114 | noggit-0.7.jar
|
---|
115 | jmorphy2-dicts-ru-0.2.0.jar"/>
|
---|
116 |
|
---|
117 |
|
---|
118 | <property name="java-service-files"
|
---|
119 | value="SolrSearch.java
|
---|
120 | GS2SolrSearch.java
|
---|
121 | GS2SolrRetrieve.java"/>
|
---|
122 |
|
---|
123 | <property name="java-util-files"
|
---|
124 | value="SolrFacetWrapper.java
|
---|
125 | SolrQueryWrapper.java
|
---|
126 | SolrQueryResult.java"/>
|
---|
127 |
|
---|
128 | <!-- <property name="property-files"
|
---|
129 | value="GS2SolrSearch.properties"/> -->
|
---|
130 |
|
---|
131 |
|
---|
132 | <!-- TARGETS -->
|
---|
133 | <target name="usage" description="Print a help message">
|
---|
134 | <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
|
---|
135 | <echo message=" Execute 'ant -help' for Ant help."/>
|
---|
136 | <echo>To install the Solr extension for Greenstone3, run 'ant add-service'.
|
---|
137 | To remove the files and folders installed by add-service, run 'ant del-service'.
|
---|
138 | </echo>
|
---|
139 | </target>
|
---|
140 |
|
---|
141 | <target name="compile" description="Compile up the solr java classes, jar them up, and install gs3-solr.jar into Greenstone's web/WEB-INF/lib dir">
|
---|
142 | <mkdir dir="${build.home}"/>
|
---|
143 | <javac srcdir="${src.home}" destdir="${build.home}" debug="true">
|
---|
144 | <classpath>
|
---|
145 | <path refid="compile.classpath"/>
|
---|
146 | </classpath>
|
---|
147 | </javac>
|
---|
148 | <jar destfile="${build.home}/gs3-solr.jar">
|
---|
149 | <fileset dir="${build.home}">
|
---|
150 | <include name="org/greenstone/gsdl3/**"/>
|
---|
151 | </fileset>
|
---|
152 | <manifest>
|
---|
153 | <attribute name="Built-By" value="${user.name}" />
|
---|
154 | </manifest>
|
---|
155 | </jar>
|
---|
156 | <copy file="${build.home}/gs3-solr.jar" todir="${web.libdir}"/>
|
---|
157 |
|
---|
158 | <!-- customisations to the http solr server -->
|
---|
159 | <jar destfile="${build.home}/gs3-solrserver.jar">
|
---|
160 | <fileset dir="${build.home}">
|
---|
161 | <include name="org/greenstone/solrserver/**"/>
|
---|
162 | </fileset>
|
---|
163 | <manifest>
|
---|
164 | <attribute name="Built-By" value="greenstone3" />
|
---|
165 | </manifest>
|
---|
166 | </jar>
|
---|
167 | <!--<copy file="${build.home}/gs3-solrserver.jar" todir="${tomcat.dir}/webapps/solr/WEB-INF/lib"/>
|
---|
168 |
|
---|
169 | But there's no guarantee the destination will exist at the beginning.
|
---|
170 | The jar file also needs to go into solr.war. Which is taken care of in the add-service task.
|
---|
171 | Instead, for testing, call ant compile-gs3-solrserver, which will copy it across to solr webapp.
|
---|
172 | -->
|
---|
173 | </target>
|
---|
174 |
|
---|
175 | <target name="copy-files" description="Helper-target: copy files across for add-service target">
|
---|
176 |
|
---|
177 | <echo/>
|
---|
178 | <!-- <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
|
---|
179 | <copy todir="${web.classesdir}">
|
---|
180 | <filelist id="prop-files" dir="properties" files="${property-files}"/>
|
---|
181 | </copy>
|
---|
182 | <echo/>-->
|
---|
183 | <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
|
---|
184 | <copy todir="${web.libdir}">
|
---|
185 | <filelist id="jar-files" dir="lib/java" files="${jars}"/>
|
---|
186 | </copy>
|
---|
187 |
|
---|
188 | <echo/>
|
---|
189 | <echo>Creating web extension directory: ${web.extdir}</echo>
|
---|
190 | <mkdir dir="${web.extdir}"/>
|
---|
191 |
|
---|
192 | <echo/>
|
---|
193 | <echo>Adding to gsdl3 web solr ext directory: solr.xml and solr.xml.in</echo>
|
---|
194 | <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml.in"/>
|
---|
195 | <pathconvert targetos="unix" property="src.gsdl3.home.unix">
|
---|
196 | <path path="../../web"/>
|
---|
197 | </pathconvert>
|
---|
198 | <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
|
---|
199 | <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
|
---|
200 |
|
---|
201 | <echo/>
|
---|
202 | <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
|
---|
203 | <copy todir="${localsite.collectdir}/solr-jdbm-demo"
|
---|
204 | preservelastmodified="true"
|
---|
205 | failonerror="true" >
|
---|
206 | <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/>
|
---|
207 | </copy>
|
---|
208 | <echo>Unzipping pre-built index</echo>
|
---|
209 | <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
|
---|
210 | </target>
|
---|
211 |
|
---|
212 | <!-- Setting up solr to work with tomcat server instead of jetty server -->
|
---|
213 | <target name="solr-for-tomcat" description="Helper-target: setting up solr to work with tomcat">
|
---|
214 |
|
---|
215 | <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
|
---|
216 | <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
|
---|
217 | <copy todir="${web.libdir}">
|
---|
218 | <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
|
---|
219 | </copy>
|
---|
220 |
|
---|
221 | <echo>Upddating xalan related jar files, morphology and gs3-solrserver jars from ${web.libdir} in solr.war</echo>
|
---|
222 | <war destfile="webapps/solr.war" update="true" >
|
---|
223 | <zipfileset dir="lib/russianmorphology" includes="*.jar" prefix="WEB-INF/lib"/>
|
---|
224 | <zipfileset dir="lib/ext" includes="*.jar" prefix="WEB-INF/lib"/>
|
---|
225 | <zipfileset dir="${web.libdir}" includes="${shared-xalan-jars}" prefix="WEB-INF/lib"/>
|
---|
226 | <zipfileset dir="${build.home}" includes="gs3-solrserver.jar" prefix="WEB-INF/lib"/>
|
---|
227 | </war>
|
---|
228 |
|
---|
229 | <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps/${solr.context}.war</echo>
|
---|
230 | <copy file="webapps/solr.war" tofile="${tomcat.dir}/webapps/${solr.context}.war" />
|
---|
231 |
|
---|
232 | <echo>Generating solr context file in ${tomcat.context.dir}</echo>
|
---|
233 |
|
---|
234 | <!-- we want unix paths (forward slashes) in the tomcat context file -->
|
---|
235 | <pathconvert targetos="unix" property="gsdl3.web.home">
|
---|
236 | <path path="${web.home}"/><!-- creates an absolute path-->
|
---|
237 | </pathconvert>
|
---|
238 | <pathconvert targetos="unix" property="tomcat.home">
|
---|
239 | <path path="${tomcat.dir}"/><!-- creates an absolute path-->
|
---|
240 | </pathconvert>
|
---|
241 | <filter token="gsdl3webhome" value="${gsdl3.web.home}"/>
|
---|
242 | <filter token="tomcathome" value="${tomcat.home}"/>
|
---|
243 | <filter token="solr.context" value="${solr.context}"/>
|
---|
244 | <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/${solr.context}.xml" filtering="true" overwrite="true"/>
|
---|
245 |
|
---|
246 | </target>
|
---|
247 |
|
---|
248 | <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
|
---|
249 | <target name="copy-solr-web" if="ext.web.exists">
|
---|
250 | <echo/>
|
---|
251 | <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
|
---|
252 | <copy todir="${web.extdir}">
|
---|
253 | <dirset dir="${basedir}/web">
|
---|
254 | <exclude name=".svn"/>
|
---|
255 | </dirset>
|
---|
256 | </copy>
|
---|
257 | </target>
|
---|
258 |
|
---|
259 |
|
---|
260 | <target name="add-service" depends="copy-solr-web,copy-files,compile,solr-for-tomcat" description="Run this target to setup the Solr extension for Greenstone3" />
|
---|
261 |
|
---|
262 | <target name="del-service" depends="del-files,del-solr-for-tomcat"
|
---|
263 | description="Run this target to unset the Solr extension for Greenstone3" />
|
---|
264 |
|
---|
265 |
|
---|
266 | <target name="del-files" description="Helper-target to delete files for del-service target">
|
---|
267 | <!-- failonerror is set to false in case some files don't exist
|
---|
268 | and can't be deleted therefore -->
|
---|
269 |
|
---|
270 | <echo/>
|
---|
271 | <!-- <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
|
---|
272 | <delete failonerror="false">
|
---|
273 | <filelist dir="${web.classesdir}" files="${property-files}"/>
|
---|
274 | </delete>
|
---|
275 |
|
---|
276 | <echo/>-->
|
---|
277 | <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
|
---|
278 | <delete failonerror="false">
|
---|
279 | <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
|
---|
280 | </delete>
|
---|
281 |
|
---|
282 | <echo/>
|
---|
283 | <echo>Removing web solr extension directory: ${web.extdir}</echo>
|
---|
284 | <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
|
---|
285 |
|
---|
286 | <echo/>
|
---|
287 | <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
|
---|
288 | <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
|
---|
289 |
|
---|
290 | </target>
|
---|
291 |
|
---|
292 | <target name="del-solr-for-tomcat" description="Helper-target to remove files for getting solr to work with tomcat">
|
---|
293 |
|
---|
294 | <echo/>
|
---|
295 | <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
|
---|
296 |
|
---|
297 | <!-- Actually need to ensure tomcat is not running at this point
|
---|
298 | But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
|
---|
299 | -->
|
---|
300 | <delete failonerror="false" file="${tomcat.dir}/webapps/${solr.context}.war"/>
|
---|
301 | <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${solr.context}"/>
|
---|
302 |
|
---|
303 | <delete failonerror="false" file="${tomcat.context.dir}/${solr.context}.xml"/>
|
---|
304 |
|
---|
305 | <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
|
---|
306 | which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
|
---|
307 | https://ant.apache.org/manual/Types/selectors.html#presentselect -->
|
---|
308 | <delete failonerror="false">
|
---|
309 | <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
|
---|
310 | <present present="both" targetdir="lib/ext"/>
|
---|
311 | </fileset>
|
---|
312 | </delete>
|
---|
313 |
|
---|
314 | <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
|
---|
315 | <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
|
---|
316 |
|
---|
317 | <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
|
---|
318 | </target>
|
---|
319 |
|
---|
320 | <target name="compile-gs3-solrserver" description="TEST Target to compile the solr server side gs3-solserver.jar for testing">
|
---|
321 | <delete dir="build/org/greenstone/solrserver" />
|
---|
322 | <delete file="build/gs3-solrserver.jar" />
|
---|
323 | <antcall target="compile" />
|
---|
324 | <copy file="${build.home}/gs3-solrserver.jar" todir="${tomcat.dir}/webapps/solr/WEB-INF/lib" />
|
---|
325 | </target>
|
---|
326 |
|
---|
327 | </project>
|
---|