source: gs3-extensions/solr/trunk/src/build.xml@ 29751

Last change on this file since 29751 was 29751, checked in by ak19, 9 years ago

On windows, ant is unable to move xercesImppl.jar file from GS3 web lib to tomcat lib, since it is on the classpath while ant is running the add-service target for solr. Similarly, can't make build.xml in toplevel GS3 move the xalan related jar files including xercesImpl.jar into tomcat after unpacking tomcat, because ant is running these commands and xercesImpl.jar is still on the PATH. The current solution is that ext\solr\build.xml repackages solr.war with copies of xalan.jar and related jar files from GS3's web lib. Now both GS3 and solr have their own copies of xalan and the related jar files (instead of the recent change, that a single shared copy of each jar exists in tomcat\lib), but these are both still guaranteed to be identical between GS3 and solr, since the solr ones are copied from GS3. As the solr.war is repackaged to contain the correct jar files, when tomcat is run, hey are unpacked and the /solr servlet can run successfully.

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