root/gs3-extensions/solr/trunk/src/build.xml @ 28124

Revision 28124, 6.1 KB (checked in by davidb, 6 years ago)

debug flag added so file and error lines are given in Exception. To consider: link this build.xml file to the top-level one so whatever setting the main Greenstone code has for this flag is used here also.

RevLine 
[25900]1<?xml version="1.0"?>
2<project name="gs3-solr-ext" default="usage" basedir=".">
3
4  <!-- DIRECTORY LOCATIONS -->
[28096]5  <!-- local ext paths -->
6  <property name="src.home" value="${basedir}/src/java"/>
7  <property name="build.home" value="${basedir}/build"/>
8
9  <!-- greenstone3 paths -->
[25900]10  <property name="web.home" value="${basedir}/../../web"/>
[27843]11  <property name="localsite.collectdir" value="${web.home}/sites/localsite/collect"/>
[28096]12 <property name="web.classesdir" value="${web.home}/WEB-INF/classes"/>
13  <property name="web.libdir" value="${web.home}/WEB-INF/lib"/> 
[25900]14  <property name="web.extdir" value="${web.home}/ext/solr"/>
[28096]15
16  <path id="compile.classpath">
17    <!-- gs3 jar files we need -->
18    <pathelement location="${web.libdir}/gsdl3.jar"/>
[28116]19    <pathelement location="${web.libdir}/gutil.jar"/>
[28096]20    <pathelement location="${web.libdir}/LuceneWrapper3.jar"/>
21    <pathelement location="${web.libdir}/gson-1.7.1.jar"/>
22    <!-- local jar files -->
23    <fileset dir="lib/java">
24      <include name="*.jar"/>
25    </fileset>
26  </path>
27
[25900]28  <!-- FILE LISTINGS.-->
29  <!-- Created as property elements rather than as filelist elements, since
30    they can then be reused for the add-service and delete-service targets. -->
31  <property name="jars"
32        value="apache-solr-core-3.3.0.jar
33        apache-solr-solrj-3.3.0.jar
34        lucene-spatial-3.3.0.jar
35        lucene-spellchecker-3.3.0.jar
36        lucene-analyzers-3.3.0.jar
37        lucene-highlighter-3.3.0.jar
38        commons-io-1.4.jar
39        commons-fileupload-1.2.1.jar
40        velocity-1.6.1.jar
41        log4j-over-slf4j-1.6.1.jar
42        slf4j-api-1.6.1.jar
43        slf4j-jdk14-1.6.1.jar"/>
44 
45  <property name="java-service-files"
[28096]46    value="SolrSearch.java         
47    GS2SolrSearch.java
48    GS2SolrRetrieve.java"/> 
[25900]49           
50  <property name="java-util-files"
[28096]51    value="SolrFacetWrapper.java
52    SolrQueryWrapper.java           
53    SolrQueryResult.java"/>           
[25900]54 
[28096]55 <!-- <property name="property-files"
56    value=""/>  -->
[25900]57
58           
59  <!-- TARGETS -->
60  <target name="usage" description="Print a help message">
61    <echo message="  Execute 'ant -projecthelp' for a list of targets."/>
62    <echo message="  Execute 'ant -help' for Ant help."/>
63    <echo>To install the Solr extension for Greenstone3, run 'ant add-service'.
64    To remove the files and folders installed by add-service, run 'ant del-service'.
65    </echo>
66  </target>         
67 
[28096]68  <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">
69    <mkdir dir="${build.home}"/>
[28124]70    <javac srcdir="${src.home}" destdir="${build.home}" debug="true">
[28096]71      <classpath>
72    <path refid="compile.classpath"/>
73      </classpath>
74    </javac>
75    <jar destfile="${build.home}/gs3-solr.jar">
76      <fileset dir="${build.home}">
77        <include name="org/greenstone/gsdl3/**"/>
78      </fileset>
79      <manifest>
80        <attribute name="Built-By" value="${user.name}" />
81      </manifest>
82    </jar>
83    <copy file="${build.home}/gs3-solr.jar" todir="${web.libdir}"/>
84  </target>
85 
[25900]86  <target name="copy-files" description="Helper-target: copy files across for add-service target">
[28096]87   
88    <!-- May want this back if we add in Solr .properties files-->
89<!--    <echo/>
[25900]90    <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
91    <copy todir="${classesdir}">
[27843]92          <filelist id="prop-files" dir="properties" files="${property-files}"/>
93    </copy>
[28096]94-->
[25900]95    <echo/>
96    <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
[28096]97    <copy todir="${web.libdir}">
[27843]98          <filelist id="jar-files" dir="lib/java" files="${jars}"/>
99    </copy>
[25900]100   
101    <echo/>
102    <echo>Creating web extension directory: ${web.extdir}</echo>
103    <mkdir dir="${web.extdir}"/>
104   
105    <echo/>
[27857]106    <echo>Adding to gsdl3 web solr ext directory: solr.xml</echo>
[27852]107    <pathconvert targetos="unix" property="src.gsdl3.home.unix">
108      <path path="../../web"/>
109    </pathconvert>
110    <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
[27857]111    <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
[25900]112   
[27843]113    <echo/>
[28096]114    <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
[27843]115    <copy todir="${localsite.collectdir}/solr-jdbm-demo"
116          preservelastmodified="true"
117          failonerror="true" > 
118      <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/> 
119    </copy>
[28100]120    <echo>Unzipping pre-built index</echo>
121    <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
[27843]122
[25900]123    <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
[27843]124    <available property="ext.web.exists" file="${basedir}/web" type="dir" />
125
[25900]126  </target>
127 
128 
[28096]129  <target name="add-service" depends="copy-files,compile" if="ext.web.exists"
[25900]130    description="Run this target to setup the Solr extension for Greenstone3">
131   
132    <echo/>
133    <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
134    <copy todir="${web.extdir}">
[27843]135          <dirset dir="${basedir}/web">
136        <exclude name=".svn"/>
137      </dirset>
138    </copy>
139
[25900]140  </target>
141 
142  <target name="del-service"
143    description="Run this target to unset the Solr extension for Greenstone3"> 
144   
145    <!-- failonerror is set to false in case some files don't exist
146    and can't be deleted therefore -->
147   
[28096]148
149<!--   
[25900]150    <echo/>
151    <echo>Removing from  gsdl3 properties area: properties/${property-files}</echo>
152    <delete failonerror="false">
[27843]153          <filelist dir="${classesdir}" files="${property-files}"/>
154    </delete>
[28096]155-->
[25900]156    <echo/>
[28096]157    <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
[25900]158    <delete failonerror="false">
[28096]159          <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
[27843]160    </delete>   
[25900]161   
162    <echo/>
163    <echo>Removing web solr extension directory: ${web.extdir}</echo>
164    <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>   
[27843]165
166    <echo/>
167    <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
168    <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
[25900]169   
170  </target>
171 
[27843]172</project>
Note: See TracBrowser for help on using the browser.