[29707] | 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 -->
|
---|
[29711] | 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 -->
|
---|
[29707] | 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 |
|
---|
[29711] | 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 |
|
---|
[29707] | 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>
|
---|
[29711] | 33 | <pathelement location="lib/servlet-api-3.0.jar"/>
|
---|
[29707] | 34 | </path>
|
---|
| 35 |
|
---|
[29711] | 36 |
|
---|
[29707] | 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"
|
---|
[29139] | 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
|
---|
[29152] | 67 | guava-14.0.1.jar
|
---|
| 68 | noggit-0.5.jar"/>
|
---|
[29139] | 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
|
---|
[29707] | 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 |
|
---|
[29714] | 83 | <property name="shared-xalan-jars"
|
---|
| 84 | value="xalan.jar
|
---|
| 85 | xercesImpl.jar
|
---|
| 86 | xml-apis.jar
|
---|
| 87 | xsltc.jar
|
---|
| 88 | serializer.jar"/>
|
---|
[29932] | 89 | <property name="russian-morph-jars"
|
---|
[31859] | 90 | value="jmorphy2-lucene-0.2.0.jar
|
---|
| 91 | jmorphy2-nlp-0.2.0.jar
|
---|
| 92 | jmorphy2-core-0.2.0.jar
|
---|
| 93 | dawg-0.2.0.jar
|
---|
| 94 | jmorphy2-dicts-uk-0.2.0.jar
|
---|
| 95 | guava-18.0.jar
|
---|
| 96 | commons-codec-1.10.jar
|
---|
| 97 | noggit-0.7.jar
|
---|
| 98 | jmorphy2-dicts-ru-0.2.0.jar"/>
|
---|
[29714] | 99 |
|
---|
[31859] | 100 |
|
---|
[29707] | 101 | <property name="java-service-files"
|
---|
| 102 | value="SolrSearch.java
|
---|
| 103 | GS2SolrSearch.java
|
---|
| 104 | GS2SolrRetrieve.java"/>
|
---|
| 105 |
|
---|
| 106 | <property name="java-util-files"
|
---|
| 107 | value="SolrFacetWrapper.java
|
---|
| 108 | SolrQueryWrapper.java
|
---|
| 109 | SolrQueryResult.java"/>
|
---|
| 110 |
|
---|
[30521] | 111 | <!-- <property name="property-files"
|
---|
| 112 | value="GS2SolrSearch.properties"/> -->
|
---|
[29707] | 113 |
|
---|
| 114 |
|
---|
| 115 | <!-- TARGETS -->
|
---|
| 116 | <target name="usage" description="Print a help message">
|
---|
| 117 | <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
|
---|
| 118 | <echo message=" Execute 'ant -help' for Ant help."/>
|
---|
| 119 | <echo>To install the Solr extension for Greenstone3, run 'ant add-service'.
|
---|
| 120 | To remove the files and folders installed by add-service, run 'ant del-service'.
|
---|
| 121 | </echo>
|
---|
| 122 | </target>
|
---|
| 123 |
|
---|
| 124 | <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">
|
---|
| 125 | <mkdir dir="${build.home}"/>
|
---|
| 126 | <javac srcdir="${src.home}" destdir="${build.home}" debug="true">
|
---|
| 127 | <classpath>
|
---|
| 128 | <path refid="compile.classpath"/>
|
---|
| 129 | </classpath>
|
---|
| 130 | </javac>
|
---|
| 131 | <jar destfile="${build.home}/gs3-solr.jar">
|
---|
| 132 | <fileset dir="${build.home}">
|
---|
| 133 | <include name="org/greenstone/gsdl3/**"/>
|
---|
| 134 | </fileset>
|
---|
| 135 | <manifest>
|
---|
| 136 | <attribute name="Built-By" value="${user.name}" />
|
---|
| 137 | </manifest>
|
---|
| 138 | </jar>
|
---|
| 139 | <copy file="${build.home}/gs3-solr.jar" todir="${web.libdir}"/>
|
---|
[29986] | 140 |
|
---|
| 141 | <!-- customisations to the http solr server -->
|
---|
| 142 | <jar destfile="${build.home}/gs3-solrserver.jar">
|
---|
| 143 | <fileset dir="${build.home}">
|
---|
| 144 | <include name="org/greenstone/solrserver/**"/>
|
---|
| 145 | </fileset>
|
---|
| 146 | <manifest>
|
---|
| 147 | <attribute name="Built-By" value="greenstone3" />
|
---|
| 148 | </manifest>
|
---|
| 149 | </jar>
|
---|
| 150 | <!--<copy file="${build.home}/gs3-solrserver.jar" todir="${tomcat.dir}/webapps/solr/WEB-INF/lib"/>
|
---|
| 151 |
|
---|
| 152 | But there's no guarantee the destination will exist at the beginning.
|
---|
| 153 | The jar file also needs to go into solr.war. Which is taken care of in the add-service task.
|
---|
| 154 | Instead, for testing, call ant compile-gs3-solrserver, which will copy it across to solr webapp.
|
---|
| 155 | -->
|
---|
[29707] | 156 | </target>
|
---|
| 157 |
|
---|
| 158 | <target name="copy-files" description="Helper-target: copy files across for add-service target">
|
---|
| 159 |
|
---|
[29542] | 160 | <echo/>
|
---|
[30521] | 161 | <!-- <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
|
---|
[29707] | 162 | <copy todir="${web.classesdir}">
|
---|
| 163 | <filelist id="prop-files" dir="properties" files="${property-files}"/>
|
---|
| 164 | </copy>
|
---|
[30521] | 165 | <echo/>-->
|
---|
[29707] | 166 | <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
|
---|
| 167 | <copy todir="${web.libdir}">
|
---|
| 168 | <filelist id="jar-files" dir="lib/java" files="${jars}"/>
|
---|
| 169 | </copy>
|
---|
| 170 |
|
---|
| 171 | <echo/>
|
---|
| 172 | <echo>Creating web extension directory: ${web.extdir}</echo>
|
---|
| 173 | <mkdir dir="${web.extdir}"/>
|
---|
| 174 |
|
---|
| 175 | <echo/>
|
---|
| 176 | <echo>Adding to gsdl3 web solr ext directory: solr.xml and solr.xml.in</echo>
|
---|
| 177 | <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml.in"/>
|
---|
| 178 | <pathconvert targetos="unix" property="src.gsdl3.home.unix">
|
---|
| 179 | <path path="../../web"/>
|
---|
| 180 | </pathconvert>
|
---|
| 181 | <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
|
---|
| 182 | <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
|
---|
| 183 |
|
---|
| 184 | <echo/>
|
---|
| 185 | <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
|
---|
| 186 | <copy todir="${localsite.collectdir}/solr-jdbm-demo"
|
---|
| 187 | preservelastmodified="true"
|
---|
| 188 | failonerror="true" >
|
---|
| 189 | <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/>
|
---|
| 190 | </copy>
|
---|
| 191 | <echo>Unzipping pre-built index</echo>
|
---|
| 192 | <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
|
---|
[29711] | 193 | </target>
|
---|
[29150] | 194 |
|
---|
[29711] | 195 | <!-- Setting up solr to work with tomcat server instead of jetty server -->
|
---|
| 196 | <target name="solr-for-tomcat" description="Helper-target: setting up solr to work tomcat">
|
---|
| 197 |
|
---|
| 198 | <echo>Copying solr jars needed for running solr with tomcat: ${basedir}/lib/ext</echo>
|
---|
| 199 | <copy todir="${tomcat.lib.dir}">
|
---|
| 200 | <fileset dir="lib/ext">
|
---|
| 201 | <include name="*.jar"/>
|
---|
| 202 | </fileset>
|
---|
| 203 | </copy>
|
---|
| 204 |
|
---|
| 205 | <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
|
---|
| 206 | <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
|
---|
| 207 | <copy todir="${web.libdir}">
|
---|
| 208 | <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
|
---|
[29751] | 209 | </copy>
|
---|
[29711] | 210 |
|
---|
| 211 | <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps</echo>
|
---|
| 212 | <copy todir="${tomcat.dir}/webapps" file="webapps/solr.war" />
|
---|
[29751] | 213 | <unwar src="${tomcat.dir}/webapps/solr.war" dest="${tomcat.dir}/webapps/solr"/>
|
---|
[29986] | 214 | <echo>Copying xalan related jar files, morphology and gs3-solrserver jars from ${web.libdir} into ${tomcat.dir}/webapps/solr.war</echo>
|
---|
[29751] | 215 | <copy todir="${tomcat.dir}/webapps/solr/WEB-INF/lib">
|
---|
| 216 | <filelist dir="${web.libdir}" files="${shared-xalan-jars}" />
|
---|
[30000] | 217 | <filelist dir="${build.home}" files="gs3-solrserver.jar" />
|
---|
[29932] | 218 | <filelist dir="lib/russianmorphology" files="${russian-morph-jars}" />
|
---|
[29751] | 219 | </copy>
|
---|
| 220 | <jar destfile="${tomcat.dir}/webapps/solr.war" basedir="${tomcat.dir}/webapps/solr" />
|
---|
| 221 | <!-- delete the webapps\solr temporary dir: tomcat will unpack the modified war file on startup-->
|
---|
| 222 | <delete failonerror="true" dir="${tomcat.dir}/webapps/solr" />
|
---|
| 223 |
|
---|
[29711] | 224 | <echo>Generating solr context file in ${tomcat.context.dir}</echo>
|
---|
| 225 |
|
---|
| 226 | <!-- we want unix paths (forward slashes) in the tomcat context file -->
|
---|
| 227 | <pathconvert targetos="unix" property="gsdl3.web.home">
|
---|
| 228 | <path path="${web.home}"/><!-- creates an absolute path-->
|
---|
| 229 | </pathconvert>
|
---|
| 230 | <pathconvert targetos="unix" property="tomcat.home">
|
---|
| 231 | <path path="${tomcat.dir}"/><!-- creates an absolute path-->
|
---|
| 232 | </pathconvert>
|
---|
[30035] | 233 | <filter token="gsdl3webhome" value="${gsdl3.web.home}"/>
|
---|
[29711] | 234 | <filter token="tomcathome" value="${tomcat.home}"/>
|
---|
| 235 | <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/solr.xml" filtering="true" overwrite="true"/>
|
---|
[29150] | 236 |
|
---|
[29711] | 237 | </target>
|
---|
| 238 |
|
---|
[29707] | 239 | <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
|
---|
| 240 | <target name="copy-solr-web" if="ext.web.exists">
|
---|
| 241 | <echo/>
|
---|
| 242 | <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
|
---|
| 243 | <copy todir="${web.extdir}">
|
---|
| 244 | <dirset dir="${basedir}/web">
|
---|
| 245 | <exclude name=".svn"/>
|
---|
| 246 | </dirset>
|
---|
| 247 | </copy>
|
---|
| 248 | </target>
|
---|
[29150] | 249 |
|
---|
[29542] | 250 |
|
---|
[29986] | 251 | <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" />
|
---|
[29707] | 252 |
|
---|
[29711] | 253 | <target name="del-service" depends="del-files,del-solr-for-tomcat"
|
---|
| 254 | description="Run this target to unset the Solr extension for Greenstone3" />
|
---|
| 255 |
|
---|
| 256 |
|
---|
| 257 | <target name="del-files" description="Helper-target to delete files for del-service target">
|
---|
[29707] | 258 | <!-- failonerror is set to false in case some files don't exist
|
---|
| 259 | and can't be deleted therefore -->
|
---|
[29542] | 260 |
|
---|
[29707] | 261 | <echo/>
|
---|
[30521] | 262 | <!-- <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
|
---|
[29707] | 263 | <delete failonerror="false">
|
---|
| 264 | <filelist dir="${web.classesdir}" files="${property-files}"/>
|
---|
| 265 | </delete>
|
---|
| 266 |
|
---|
[30521] | 267 | <echo/>-->
|
---|
[29707] | 268 | <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
|
---|
| 269 | <delete failonerror="false">
|
---|
| 270 | <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
|
---|
| 271 | </delete>
|
---|
| 272 |
|
---|
| 273 | <echo/>
|
---|
| 274 | <echo>Removing web solr extension directory: ${web.extdir}</echo>
|
---|
| 275 | <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
|
---|
| 276 |
|
---|
| 277 | <echo/>
|
---|
| 278 | <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
|
---|
[29711] | 279 | <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
|
---|
| 280 |
|
---|
[29707] | 281 | </target>
|
---|
| 282 |
|
---|
[29711] | 283 | <target name="del-solr-for-tomcat" description="Helper-target to remove files for getting solr to work with tomcat">
|
---|
| 284 |
|
---|
| 285 | <echo/>
|
---|
| 286 | <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
|
---|
| 287 |
|
---|
| 288 | <!-- Actually need to ensure tomcat is not running at this point
|
---|
| 289 | But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
|
---|
| 290 | -->
|
---|
| 291 | <delete failonerror="false" file="${tomcat.dir}/webapps/solr.war"/>
|
---|
| 292 | <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/solr"/>
|
---|
| 293 |
|
---|
| 294 | <delete failonerror="false" file="${tomcat.context.dir}/solr.xml"/>
|
---|
| 295 |
|
---|
| 296 | <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
|
---|
| 297 | which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
|
---|
| 298 | https://ant.apache.org/manual/Types/selectors.html#presentselect -->
|
---|
| 299 | <delete failonerror="false">
|
---|
| 300 | <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
|
---|
| 301 | <present present="both" targetdir="lib/ext"/>
|
---|
| 302 | </fileset>
|
---|
| 303 | </delete>
|
---|
| 304 |
|
---|
| 305 | <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
|
---|
| 306 | <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
|
---|
| 307 |
|
---|
| 308 | <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
|
---|
| 309 | </target>
|
---|
| 310 |
|
---|
[29986] | 311 | <target name="compile-gs3-solrserver" description="TEST Target to compile the solr server side gs3-solserver.jar for testing">
|
---|
| 312 | <delete dir="build/org/greenstone/solrserver" />
|
---|
| 313 | <delete file="build/gs3-solrserver.jar" />
|
---|
| 314 | <antcall target="compile" />
|
---|
| 315 | <copy file="${build.home}/gs3-solrserver.jar" todir="${tomcat.dir}/webapps/solr/WEB-INF/lib" />
|
---|
| 316 | </target>
|
---|
| 317 |
|
---|
[29707] | 318 | </project>
|
---|