[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"/>
|
---|
| 89 |
|
---|
[29707] | 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 |
|
---|
[29542] | 100 | <property name="property-files"
|
---|
[29707] | 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 |
|
---|
[29542] | 133 | <echo/>
|
---|
[29707] | 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" />
|
---|
[29711] | 166 | </target>
|
---|
[29150] | 167 |
|
---|
[29711] | 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>
|
---|
[29707] | 183 |
|
---|
[29711] | 184 | <echo>Moving xalan related jar files from ${web.libdir} to ${tomcat.lib.dir}, to share with solr</echo>
|
---|
| 185 | <move todir="${tomcat.lib.dir}">
|
---|
[29714] | 186 | <filelist dir="${web.libdir}" files="${shared-xalan-jars}" />
|
---|
[29711] | 187 | </move>
|
---|
| 188 |
|
---|
| 189 | <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps</echo>
|
---|
| 190 | <copy todir="${tomcat.dir}/webapps" file="webapps/solr.war" />
|
---|
| 191 | <echo>Generating solr context file in ${tomcat.context.dir}</echo>
|
---|
| 192 |
|
---|
| 193 | <!-- we want unix paths (forward slashes) in the tomcat context file -->
|
---|
| 194 | <pathconvert targetos="unix" property="gsdl3.web.home">
|
---|
| 195 | <path path="${web.home}"/><!-- creates an absolute path-->
|
---|
| 196 | </pathconvert>
|
---|
| 197 | <pathconvert targetos="unix" property="tomcat.home">
|
---|
| 198 | <path path="${tomcat.dir}"/><!-- creates an absolute path-->
|
---|
| 199 | </pathconvert>
|
---|
| 200 | <filter token="gsdl3home" value="${gsdl3.web.home}"/>
|
---|
| 201 | <filter token="tomcathome" value="${tomcat.home}"/>
|
---|
| 202 | <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/solr.xml" filtering="true" overwrite="true"/>
|
---|
[29150] | 203 |
|
---|
[29711] | 204 | </target>
|
---|
| 205 |
|
---|
[29707] | 206 | <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
|
---|
| 207 | <target name="copy-solr-web" if="ext.web.exists">
|
---|
| 208 | <echo/>
|
---|
| 209 | <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
|
---|
| 210 | <copy todir="${web.extdir}">
|
---|
| 211 | <dirset dir="${basedir}/web">
|
---|
| 212 | <exclude name=".svn"/>
|
---|
| 213 | </dirset>
|
---|
| 214 | </copy>
|
---|
| 215 | </target>
|
---|
[29150] | 216 |
|
---|
[29542] | 217 |
|
---|
[29711] | 218 | <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" />
|
---|
[29707] | 219 |
|
---|
[29711] | 220 | <target name="del-service" depends="del-files,del-solr-for-tomcat"
|
---|
| 221 | description="Run this target to unset the Solr extension for Greenstone3" />
|
---|
| 222 |
|
---|
| 223 |
|
---|
| 224 | <target name="del-files" description="Helper-target to delete files for del-service target">
|
---|
[29707] | 225 | <!-- failonerror is set to false in case some files don't exist
|
---|
| 226 | and can't be deleted therefore -->
|
---|
[29542] | 227 |
|
---|
[29707] | 228 | <echo/>
|
---|
[29711] | 229 | <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
|
---|
[29707] | 230 | <delete failonerror="false">
|
---|
| 231 | <filelist dir="${web.classesdir}" files="${property-files}"/>
|
---|
| 232 | </delete>
|
---|
| 233 |
|
---|
| 234 | <echo/>
|
---|
| 235 | <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
|
---|
| 236 | <delete failonerror="false">
|
---|
| 237 | <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
|
---|
| 238 | </delete>
|
---|
| 239 |
|
---|
| 240 | <echo/>
|
---|
| 241 | <echo>Removing web solr extension directory: ${web.extdir}</echo>
|
---|
| 242 | <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
|
---|
| 243 |
|
---|
| 244 | <echo/>
|
---|
| 245 | <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
|
---|
[29711] | 246 | <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
|
---|
| 247 |
|
---|
[29707] | 248 | </target>
|
---|
| 249 |
|
---|
[29711] | 250 | <target name="del-solr-for-tomcat" description="Helper-target to remove files for getting solr to work with tomcat">
|
---|
| 251 |
|
---|
| 252 | <echo/>
|
---|
| 253 | <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
|
---|
| 254 |
|
---|
| 255 | <!-- Actually need to ensure tomcat is not running at this point
|
---|
| 256 | But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
|
---|
| 257 | -->
|
---|
| 258 | <delete failonerror="false" file="${tomcat.dir}/webapps/solr.war"/>
|
---|
| 259 | <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/solr"/>
|
---|
| 260 |
|
---|
| 261 | <delete failonerror="false" file="${tomcat.context.dir}/solr.xml"/>
|
---|
| 262 |
|
---|
| 263 | <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
|
---|
| 264 | which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
|
---|
| 265 | https://ant.apache.org/manual/Types/selectors.html#presentselect -->
|
---|
| 266 | <delete failonerror="false">
|
---|
| 267 | <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
|
---|
| 268 | <present present="both" targetdir="lib/ext"/>
|
---|
| 269 | </fileset>
|
---|
| 270 | </delete>
|
---|
| 271 |
|
---|
| 272 | <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
|
---|
| 273 | <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
|
---|
| 274 |
|
---|
| 275 | <!-- moving shared xalan related jar files back from tomcat lib to GS3 web lib -->
|
---|
| 276 | <move todir="${web.libdir}">
|
---|
[29714] | 277 | <filelist dir="${tomcat.lib.dir}" files="${shared-xalan-jars}" />
|
---|
[29711] | 278 | </move>
|
---|
| 279 |
|
---|
| 280 | <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
|
---|
| 281 | </target>
|
---|
| 282 |
|
---|
[29707] | 283 | </project>
|
---|