source: gs3-extensions/webswing/trunk/build.xml@ 36526

Last change on this file since 36526 was 36526, checked in by davidb, 20 months ago

Configuring of config files now operational

File size: 12.7 KB
Line 
1<?xml version="1.0"?>
2<project name="gs3-webswing-ext" default="usage" basedir=".">
3
4 <!-- ============ classpath =================== -->
5 <path id="project.classpath">
6 <fileset dir="../../lib/java">
7 <include name="**/*.jar"/>
8 </fileset>
9 </path>
10
11 <!-- ============ self defined tasks =================== -->
12 <taskdef name="mysetproxy" classname="org.greenstone.anttasks.MySetProxy" classpathref="project.classpath"/>
13 <taskdef name="getuserandpassword" classname="org.greenstone.anttasks.MyGetUserAndPassword" classpathref="project.classpath"/>
14 <taskdef name="rsr" classname="org.greenstone.anttasks.RegexSearchReplace" classpathref="project.classpath"/>
15 <!--<taskdef name="svn" classname="org.tigris.subversion.svnant.SvnTask" classpathref="project.classpath"/>-->
16 <taskdef name="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
17 <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
18 <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpathref="project.classpath"/>
19 <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
20
21
22 <!-- Perhaps the following needs to be moved into a sub-module/sub-projectc so it can be imported (<import file="....xml") -->
23
24 <property name="os.linux" value="Linux"/>
25 <property name="os.mac" value="Mac OS X"/>
26 <property name="os.solaris" value="SunOS"/>
27 <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
28 <property name="os.windows" value="Windows 95,Windows 98,Windows 2000,Windows 2003,Windows XP,Windows NT,Windows ME,Windows Vista,Windows 7,Windows Server 2008,Windows Server 2008 R2,Windows 8,Windows 10,Windows 11"/> <!-- check this!!!-->
29
30
31 <property environment="env"/>
32
33 <!-- DIRECTORY LOCATIONS -->
34 <!-- local ext paths -->
35 <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
36 <property name="src.home" value="${basedir}/src"/>
37 <property name="dst.home" value="${basedir}/web"/>
38 <available property="ext.web.exists" file="${basedir}/web" type="dir" />
39
40
41 <!-- greenstone3 paths -->
42 <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
43 http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
44
45 <property name="gsdl3srchome" location="${basedir}/../.."/> <!-- location property creates an absolute path -->
46 <property name="web.home" location="${basedir}/../../web"/> <!-- location property creates an absolute path -->
47 <property name="web.extdir" value="${web.home}/ext/webswing"/>
48
49
50 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
51 <and>
52 <isset property="gs3.tomcat.installed.path"/>
53 <not>
54 <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
55 </not>
56 </and>
57 </condition>
58 <condition property="webswing.context" value="${gs3.webswing.context}" else="webswing">
59 <and>
60 <isset property="gs3.webswing.context"/>
61 <not>
62 <equals arg1="${gs3.webswing.context}" arg2=""/>
63 </not>
64 </and>
65 </condition>
66
67 <!--
68 <condition property="compile.javac.flags" value="${env.JAVACFLAGS}" else="">
69 <isset property="env.JAVACFLAGS"/>
70 </condition>
71 -->
72
73 <!-- FILE LISTINGS.-->
74 <!-- Created as property elements rather than as filelist elements, since
75 they can then be reused for the add-service and delete-service targets. -->
76 <!--
77 <property name="config-files"
78 value="${dst.home}/webswing.config
79 ${dst.home}/webswing.properties"/>
80
81 -->
82
83 <!-- TARGETS -->
84 <target name="usage" description="Print a help message">
85 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
86 <echo message=" Execute 'ant -help' for Ant help."/>
87 <echo>To install the Webswing extension for Greenstone3, run 'ant add-webapp'.
88 To remove the files and folders installed by add-service, run 'ant del-webapp'.
89 </echo>
90 </target>
91
92 <target name="compile" description="Compile up the webswing java classes, war them up, and install webseing-server.war into Greenstone's Tomcats webapps dir">
93
94 <exec os="${os.unix}" executable="bash" dir="src" failonerror="true">
95 <arg value="-c" />
96 <arg value="./COMPILE.sh" />
97 </exec>
98
99 <echo>Copying src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war ${tomcat.dir}/webapps </echo>
100 <copy file="src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war" todir="${tomcat.dir}/webapps"/>
101
102 </target>
103
104 <target name="clean" description="Delete the webswing compiled classes">
105 <exec os="${os.unix}" executable="./CLEAN.sh" dir="src" failonerror="true" />
106 <exec os="${os.windows}" executable=".\\CLEAN.bat" dir="src" failonerror="true" />
107 </target>
108
109 <property name="etc-config-files" value="catalina-opts-extra.args,webswing.config,webswing.properties"/>
110 <property name="etc-config-dirs" value="api,apps,fonts,ssl"/>
111
112 <target name="install-etc-files" description="Helper-target: copy web/etc config files across for add-extension target">
113
114 <echo/>
115 <!--
116 <echo>Adding to gsdl3 properties area: properties/${property-files}</echo>
117 <copy todir="${web.classesdir}">
118 <filelist id="prop-files" dir="properties" files="${property-files}"/>
119 </copy>
120 <echo/>
121 -->
122
123 <!--
124 <echo>Adding to gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars}</echo>
125 <copy todir="${web.libdir}">
126 <filelist id="jar-files" dir="lib/java" files="${jars}"/>
127 </copy>
128 -->
129
130
131 <if>
132 <bool><not><available file="${web.extdir}" type="dir"/></not></bool>
133 <echo>Creating web extension directory: ${web.extdir}</echo>
134 <mkdir dir="${web.extdir}"/>
135 </if>
136 <if>
137 <bool><not><available file="${web.extdir}/etc" type="dir"/></not></bool>
138 <echo>Creating web extension directory: ${web.extdir}/etc</echo>
139 <mkdir dir="${web.extdir}/etc"/>
140 </if>
141
142 <for param="configFile" list="${etc-config-files}">
143 <sequential>
144 <echo message="Processing ${basedir}/web/etc/@{configFile}.in"/>
145 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir}/etc/@{configFile}" filtering="true" overwrite="true">
146 <filterset>
147 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
148 </filterset>
149 </copy>
150 </sequential>
151 </for>
152
153 <for param="configDir" list="${etc-config-dirs}">
154 <sequential>
155 <echo/>
156 <echo>Installing ${basedir}/web/@{configDir}/ (excluding .svn)</echo>
157 <copy todir="${web.extdir}">
158 <fileset dir="${basedir}/web">
159 <include name="@{configDir}/**"/>
160 <exclude name="**/.svn"/>
161 </fileset>
162 </copy>
163 </sequential>
164 </for>
165
166 <!--
167
168 <echo/>
169 <echo>Adding to gsdl3 web solr ext directory: solr.xml and solr.xml.in</echo>
170 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml.in"/>
171 <pathconvert targetos="unix" property="src.gsdl3.home.unix">
172 <path path="../../web"/>
173 </pathconvert>
174 <filter token="gsdl3home" value="${src.gsdl3.home.unix}"/>
175 <copy file="solr.xml.in" tofile="${web.extdir}/solr.xml" filtering="true" overwrite="true"/>
176
177 <echo/>
178 <echo>Adding example solr-jdbm-demo collection to ${localsite.collectdir}</echo>
179 <copy todir="${localsite.collectdir}/solr-jdbm-demo"
180 preservelastmodified="true"
181 failonerror="true" >
182 <fileset dir="${basedir}/collect/solr-jdbm-demo" includes="**"/>
183 </copy>
184 <echo>Unzipping pre-built index</echo>
185 <unzip dest="${localsite.collectdir}/solr-jdbm-demo" src="${localsite.collectdir}/solr-jdbm-demo/index.zip" />
186
187 -->
188 </target>
189
190 <target name="copy-etc-file">
191 <echo message="Copying ${theConfigFile} to ${web.extdir}/webswing/etc"/>
192 </target>
193
194 <!-- Setting up solr to work with tomcat server instead of jetty server -->
195 <target name="install-webswing-for-tomcat" description="Helper-target: setting up webswing to work with tomcat">
196
197 <!-- slf4j and commons logging bridge needed to avoid exception about incompatibility in tomcat log files-->
198 <echo>Copying ${basedir}/lib/ext/jcl-over-slf4j-1.6.6.jar again to ${web.libdir}</echo>
199 <copy todir="${web.libdir}">
200 <filelist id="logging-bridge" dir="lib/ext" files="jcl-over-slf4j-1.6.6.jar"/>
201 </copy>
202
203 <echo>Upddating xalan related jar files, morphology and gs3-solrserver jars from ${web.libdir} in solr.war</echo>
204 <war destfile="webapps/solr.war" update="true" >
205 <zipfileset dir="lib/russianmorphology" includes="*.jar" prefix="WEB-INF/lib"/>
206 <zipfileset dir="lib/ext" includes="*.jar" prefix="WEB-INF/lib"/>
207 <zipfileset dir="${web.libdir}" includes="${shared-xalan-jars}" prefix="WEB-INF/lib"/>
208 <zipfileset dir="${build.home}" includes="gs3-solrserver.jar" prefix="WEB-INF/lib"/>
209 </war>
210
211 <echo>Copying ${basedir}/webapps/solr.war to ${tomcat.dir}/webapps/${solr.context}.war</echo>
212 <copy file="webapps/solr.war" tofile="${tomcat.dir}/webapps/${solr.context}.war" />
213
214 <echo>Generating solr context file in ${tomcat.context.dir}</echo>
215
216 <!-- we want unix paths (forward slashes) in the tomcat context file -->
217 <pathconvert targetos="unix" property="gsdl3.web.home">
218 <path path="${web.home}"/><!-- creates an absolute path-->
219 </pathconvert>
220 <pathconvert targetos="unix" property="tomcat.home">
221 <path path="${tomcat.dir}"/><!-- creates an absolute path-->
222 </pathconvert>
223 <filter token="gsdl3webhome" value="${gsdl3.web.home}"/>
224 <filter token="tomcathome" value="${tomcat.home}"/>
225 <filter token="solr.context" value="${solr.context}"/>
226 <copy file="solr-tomcat-context.xml.in" tofile="${tomcat.context.dir}/${solr.context}.xml" filtering="true" overwrite="true"/>
227
228 </target>
229
230 <!-- copy the content of the web folder (avoiding the top-level .svn directory) -->
231 <!--
232 <target name="install-solr-web" if="ext.web.exists">
233 <echo/>
234 <echo>Copy to gsdl3 web: the content of the ${basedir}/web folder (excluding .svn)</echo>
235 <copy todir="${web.extdir}">
236 <dirset dir="${basedir}/web">
237 <exclude name=".svn"/>
238 </dirset>
239 </copy>
240 </target>
241
242 -->
243
244 <target name="add-extension" depends="install-etc-files,install-webswing-for-tomcat"
245 description="Run this target to setup the Webswing extension for Greenstone3" />
246
247 <target name="del-extension" depends="del-etc-files,del-webswing-for-tomcat"
248 description="Run this target to unset the Webswing extension for Greenstone3" />
249
250
251 <target name="del-etc-files" description="Helper-target to delete files for del-extension target">
252 <!-- failonerror is set to false in case some files don't exist
253 and can't be deleted therefore -->
254
255 <echo/>
256<!-- <echo>Removing from gsdl3 properties area: properties/${property-files}</echo>
257 <delete failonerror="false">
258 <filelist dir="${web.classesdir}" files="${property-files}"/>
259 </delete>
260
261 <echo/>-->
262 <echo>Removing from gsdl3 web jar lib directory: ${basedir}/lib/java's ${jars} gs3-solr.jar</echo>
263 <delete failonerror="false">
264 <filelist dir="${web.libdir}" files="${jars} gs3-solr.jar"/>
265 </delete>
266
267 <echo/>
268 <echo>Removing web solr extension directory: ${web.extdir}</echo>
269 <delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}"/>
270
271 <echo/>
272 <echo>Removing solr-jdbm-demo collection from: ${localsite.collectdir}</echo>
273 <delete failonerror="false" includeEmptyDirs="true" dir="${localsite.collectcdir}/solr-jdbm-demo"/>
274
275 </target>
276
277 <target name="del-webswing-for-tomcat" description="Helper-target to remove files for getting webswing to work with tomcat">
278
279 <echo/>
280 <echo>Removing solr modifications to tomcat: context file, solr.war and deployed version, jar files</echo>
281
282 <!-- Actually need to ensure tomcat is not running at this point
283 But if solr.war is deleted first, it can't be re-deployed when deleting the solr folder subsequently
284 -->
285 <delete failonerror="false" file="${tomcat.dir}/webapps/${solr.context}.war"/>
286 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${solr.context}"/>
287
288 <delete failonerror="false" file="${tomcat.context.dir}/${solr.context}.xml"/>
289
290 <!-- delete all the jar files in tomcat/lib that were copied from ext/solr/lib/ext
291 which are all the jar files that are present in both tomcat/lib and ext/solr/lib/ext
292 https://ant.apache.org/manual/Types/selectors.html#presentselect -->
293 <delete failonerror="false">
294 <fileset dir="${tomcat.lib.dir}" includes="**/*.jar">
295 <present present="both" targetdir="lib/ext"/>
296 </fileset>
297 </delete>
298
299 <!-- remove logging bridge jar file that was added into greenstone 3 web lib area -->
300 <delete failonerror="false" file="${web.libdir}/jcl-over-slf4j-1.6.6.jar"/>
301
302 <!--http://stackoverflow.com/questions/2140637/how-do-i-build-a-list-of-file-names-->
303 </target>
304
305</project>
Note: See TracBrowser for help on using the repository browser.