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

Last change on this file since 29932 was 29932, checked in by Georgiy Litvinov, 9 years ago

Added russian morpology analyzer

File size: 11.3 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 <property name="russian-morph-jars"
90 value="russian-4.7.2.jar
91 morph-4.7.2.jar"/>
92
93 <property name="java-service-files"
94 value="SolrSearch.java
95 GS2SolrSearch.java
96 GS2SolrRetrieve.java"/>
97
98 <property name="java-util-files"
99 value="SolrFacetWrapper.java
100 SolrQueryWrapper.java
101 SolrQueryResult.java"/>
102
103 <property name="property-files"
104 value="GS2SolrSearch.properties"/>
105
106
107 <!-- TARGETS -->
108 <target name="usage" description="Print a help message">
109 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
110 <echo message=" Execute 'ant -help' for Ant help."/>
111 <echo>To install the Solr extension for Greenstone3, run 'ant add-service'.
112 To remove the files and folders installed by add-service, run 'ant del-service'.
113 </echo>
114 </target>
115
116 <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">
117 <mkdir dir="${build.home}"/>
118 <javac srcdir="${src.home}" destdir="${build.home}" debug="true">
119 <classpath>
120 <path refid="compile.classpath"/>
121 </classpath>
122 </javac>
123 <jar destfile="${build.home}/gs3-solr.jar">
124 <fileset dir="${build.home}">
125 <include name="org/greenstone/gsdl3/**"/>
126 </fileset>
127 <manifest>
128 <attribute name="Built-By" value="${user.name}" />
129 </manifest>
130 </jar>
131 <copy file="${build.home}/gs3-solr.jar" todir="${web.libdir}"/>
132 </target>
133
134 <target name="copy-files" description="Helper-target: copy files across for add-service target">
135
136 <echo/>
137 <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
138 <copy todir="${web.classesdir}">
139 <filelist id="prop-files" dir="properties" files="${property-files}"/>
140 </copy>
141 <echo/>
142 <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
143 <copy todir="${web.libdir}">
144 <filelist id="jar-files" dir="lib/java" files="${jars}"/>
145 </copy>
146
147 <echo/>
148 <echo>Creating web extension directory: ${web.extdir}</echo>
149 <mkdir dir="${web.extdir}"/>
150
151 <echo/>
152 <echo>Adding to gsdl3 web solr ext directory: solr.xml and solr.xml.in</echo>
153 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml.in"/>
154 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
155 <path path="../../web"/>
156 </pathconvert>
157 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
158 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
159
160 <echo/>
161 <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
162 <copy todir="${localsite.collectdir}/solr-jdbm-demo"
163 preservelastmodified="true"
164 failonerror="true" >
165 <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/>
166 </copy>
167 <echo>Unzipping pre-built index</echo>
168 <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
169 </target>
170
171 <!-- Setting up solr to work with tomcat server instead of jetty server -->
172 <target name="solr-for-tomcat" description="Helper-target: setting up solr to work tomcat">
173
174 <echo>Copying solr jars needed for running solr with tomcat: ${basedir}/lib/ext</echo>
175 <copy todir="${tomcat.lib.dir}">
176 <fileset dir="lib/ext">
177 <include name="*.jar"/>
178 </fileset>
179 </copy>
180
181 <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
182 <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
183 <copy todir="${web.libdir}">
184 <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
185 </copy>
186
187 <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps</echo>
188 <copy todir="${tomcat.dir}/webapps" file="webapps/solr.war" />
189 <unwar src="${tomcat.dir}/webapps/solr.war" dest="${tomcat.dir}/webapps/solr"/>
190 <echo>Copying xalan related jar files from ${web.libdir} into ${tomcat.dir}/webapps/solr.war</echo>
191 <copy todir="${tomcat.dir}/webapps/solr/WEB-INF/lib">
192 <filelist dir="${web.libdir}" files="${shared-xalan-jars}" />
193 <filelist dir="lib/russianmorphology" files="${russian-morph-jars}" />
194 </copy>
195 <jar destfile="${tomcat.dir}/webapps/solr.war" basedir="${tomcat.dir}/webapps/solr" />
196 <!-- delete the webapps\solr temporary dir: tomcat will unpack the modified war file on startup-->
197 <delete failonerror="true" dir="${tomcat.dir}/webapps/solr" />
198
199 <echo>Generating solr context file in ${tomcat.context.dir}</echo>
200
201 <!-- we want unix paths (forward slashes) in the tomcat context file -->
202 <pathconvert targetos="unix" property="gsdl3.web.home">
203 <path path="${web.home}"/><!-- creates an absolute path-->
204 </pathconvert>
205 <pathconvert targetos="unix" property="tomcat.home">
206 <path path="${tomcat.dir}"/><!-- creates an absolute path-->
207 </pathconvert>
208 <filter token="gsdl3home" value="${gsdl3.web.home}"/>
209 <filter token="tomcathome" value="${tomcat.home}"/>
210 <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/solr.xml" filtering="true" overwrite="true"/>
211
212 </target>
213
214 <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
215 <target name="copy-solr-web" if="ext.web.exists">
216 <echo/>
217 <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
218 <copy todir="${web.extdir}">
219 <dirset dir="${basedir}/web">
220 <exclude name=".svn"/>
221 </dirset>
222 </copy>
223 </target>
224
225
226 <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" />
227
228 <target name="del-service" depends="del-files,del-solr-for-tomcat"
229 description="Run this target to unset the Solr extension for Greenstone3" />
230
231
232 <target name="del-files" description="Helper-target to delete files for del-service target">
233 <!-- failonerror is set to false in case some files don't exist
234 and can't be deleted therefore -->
235
236 <echo/>
237 <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
238 <delete failonerror="false">
239 <filelist dir="${web.classesdir}" files="${property-files}"/>
240 </delete>
241
242 <echo/>
243 <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
244 <delete failonerror="false">
245 <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
246 </delete>
247
248 <echo/>
249 <echo>Removing web solr extension directory: ${web.extdir}</echo>
250 <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
251
252 <echo/>
253 <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
254 <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
255
256 </target>
257
258 <target name="del-solr-for-tomcat" description="Helper-target to remove files for getting solr to work with tomcat">
259
260 <echo/>
261 <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
262
263 <!-- Actually need to ensure tomcat is not running at this point
264 But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
265 -->
266 <delete failonerror="false" file="${tomcat.dir}/webapps/solr.war"/>
267 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/solr"/>
268
269 <delete failonerror="false" file="${tomcat.context.dir}/solr.xml"/>
270
271 <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
272 which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
273 https://ant.apache.org/manual/Types/selectors.html#presentselect -->
274 <delete failonerror="false">
275 <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
276 <present present="both" targetdir="lib/ext"/>
277 </fileset>
278 </delete>
279
280 <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
281 <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
282
283 <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
284 </target>
285
286</project>
Note: See TracBrowser for help on using the repository browser.