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

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

More nuanced install/configure targets, so when top-level build.xml does an 'ant start' it now reconfigures the necessary webswing config files

File size: 8.3 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="if" classname="ise.antelope.tasks.IfTask" classpathref="project.classpath"/>
16 <taskdef name="for" classname="net.sf.antcontrib.logic.ForTask" classpathref="project.classpath"/>
17 <taskdef name="foreach" classname="net.sf.antcontrib.logic.ForEach" classpathref="project.classpath"/>
18 <taskdef name="stringutil" classname="ise.antelope.tasks.StringUtilTask" classpathref="project.classpath"/>
19
20 <!--
21 Perhaps the following (and the above) should bo be moved into a sub-module/sub-projectc so it can be imported
22 (<import file="<filename>.xml")
23 -->
24
25 <property name="os.linux" value="Linux"/>
26 <property name="os.mac" value="Mac OS X"/>
27 <property name="os.solaris" value="SunOS"/>
28 <property name="os.unix" value="${os.linux},${os.mac},${os.solaris}"/>
29 <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!!!-->
30
31 <!--
32 <property environment="env"/>
33 -->
34
35 <!-- Directory Locations -->
36 <!-- http://stackoverflow.com/questions/3136849/how-do-i-convert-a-relative-path-in-ant-to-an-absolute-path
37 http://stackoverflow.com/questions/8295860/pathconvert-with-relative-file-names -->
38
39 <!-- greenstone3 paths -->
40 <property name="gsdl3srchome" location="${basedir}/../.."/> <!-- location property creates an absolute path -->
41 <property name="web.home" location="${basedir}/../../web"/> <!-- location property creates an absolute path, default if not set with -D argument -->
42 <property name="web.writablehome" location="${basedir}/../../web"/> <!-- location property creates an absolute path, default if not set with -D argument -->
43 <property name="web.extdir" value="${web.writablehome}/ext/webswing"/>
44
45 <!-- local ext paths -->
46 <loadproperties prefix="gs3." srcFile="${basedir}/../../build.properties"/>
47 <property name="src.home" value="${basedir}/src"/>
48 <property name="dst.home" value="${basedir}/web"/>
49 <available property="ext.web.exists" file="${basedir}/web" type="dir" />
50
51 <property name="etc-config-files" value="catalina-opts-extra.args,webswing.config,webswing.properties"/>
52 <property name="etc-config-dirs" value="api,apps,fonts,ssl"/>
53
54 <condition property="tomcat.dir" value="${gs3.tomcat.installed.path}" else="${basedir}/../../packages/tomcat">
55 <and>
56 <isset property="gs3.tomcat.installed.path"/>
57 <not>
58 <equals arg1="${gs3.tomcat.installed.path}" arg2=""/>
59 </not>
60 </and>
61 </condition>
62 <condition property="webswing.context" value="${gs3.webswing.context}" else="webswing-server">
63 <and>
64 <isset property="gs3.webswing.context"/>
65 <not>
66 <equals arg1="${gs3.webswing.context}" arg2=""/>
67 </not>
68 </and>
69 </condition>
70
71
72 <!-- TARGETS -->
73 <target name="usage" description="Print a help message">
74 <echo message=" Execute 'ant -projecthelp' for a list of targets."/>
75 <echo message=" Execute 'ant -help' for Ant help."/>
76 <echo>To install the Webswing extension for Greenstone3, run 'ant add-webapp'.
77 To remove the files and folders installed by add-service, run 'ant del-webapp'.
78 </echo>
79 </target>
80
81 <target name="compile" description="Compile up the webswing java classes, war them up, and install webseing-server.war into Greenstone's Tomcats webapps dir">
82
83 <exec os="${os.unix}" executable="bash" dir="src" failonerror="true">
84 <arg value="-c" />
85 <arg value="./COMPILE.sh" />
86 </exec>
87
88 <echo>Copying src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war ${tomcat.dir}/webapps </echo>
89 <copy file="src/webswing-20.2.5/webswing-server/webswing-server-war/target/webswing-server.war" todir="${tomcat.dir}/webapps"/>
90
91 </target>
92
93 <target name="clean" description="Delete the webswing compiled classes">
94 <exec os="${os.unix}" executable="./CLEAN.sh" dir="src" failonerror="true" />
95 <exec os="${os.windows}" executable=".\\CLEAN.bat" dir="src" failonerror="true" />
96 </target>
97
98
99 <target name="install-etc-files">
100
101 <if>
102 <bool><not><available file="${web.extdir}" type="dir"/></not></bool>
103 <echo>Creating web extension directory: ${web.extdir}</echo>
104 <mkdir dir="${web.extdir}"/>
105 </if>
106 <if>
107 <bool><not><available file="${web.extdir}/etc" type="dir"/></not></bool>
108 <echo>Creating web extension directory: ${web.extdir}/etc</echo>
109 <mkdir dir="${web.extdir}/etc"/>
110 </if>
111
112 <for param="configFile" list="${etc-config-files}">
113 <sequential>
114 <echo message="Installing ${basedir}/web/etc/@{configFile}.in"/>
115 <copy file="${basedir}/web/etc/@{configFile}.in" tofile="${web.extdir}/etc/@{configFile}.in" overwrite="true" />
116 </sequential>
117 </for>
118
119 <for param="configDir" list="${etc-config-dirs}">
120 <sequential>
121 <echo/>
122 <echo>Installing directory ${basedir}/web/@{configDir}/ (excluding .svn)</echo>
123 <copy todir="${web.extdir}">
124 <fileset dir="${basedir}/web">
125 <include name="@{configDir}/**"/>
126 <exclude name="**/.svn"/>
127 </fileset>
128 </copy>
129 </sequential>
130 </for>
131 </target>
132
133 <target name="install-webswing-for-tomcat">
134 <echo>Copying ${basedir}/web/webswing-server.war to ${tomcat.dir}/webapps/${webswing.context}.war</echo>
135 <copy file="${basedir}/web/webswing-server.war" tofile="${tomcat.dir}/webapps/${webswing.context}.war" />
136 </target>
137
138
139 <target name="add-extension" depends="install-etc-files,install-webswing-for-tomcat"
140 description="Run this target to setup the Webswing extension for Greenstone3" />
141
142
143 <target name="configure-extension">
144 <for param="configFile" list="${etc-config-files}">
145 <sequential>
146 <echo message="Configuring ${web.extdir}/etc/@{configFile}"/>
147 <copy file="${web.extdir}/etc/@{configFile}.in" tofile="${web.extdir}/etc/@{configFile}" filtering="true" overwrite="true">
148 <filterset>
149 <filter token="gsdl3srchome" value="${gsdl3srchome}"/>
150 </filterset>
151 </copy>
152 </sequential>
153 </for>
154 </target>
155
156 <target name="accept-del-extension" unless="delextension.accepted">
157 <input addproperty="delextension.ok" validargs="y,n">This will recursively delete all the files in:
158 ${web.extdir}
159Do you want to continue [y/n]
160 </input>
161 <condition property="do.abort-delextension">
162 <equals arg1="n" arg2="${delextension.ok}"/>
163 </condition>
164 <fail if="do.abort-delextension">... Exiting</fail>
165 </target>
166
167 <target name="del-etc-files" description="Helper-target to delete webswing installed files">
168 <!-- failonerror is set to false in case some files don't exist
169 and can't be deleted therefore -->
170 <echo/>
171 <echo>Removing 'webswing' from ${web.extdir}</echo>
172 <echo>
173 delete failonerror="false" includeEmptyDirs="true" dir="${web.extdir}/webswing"
174 </echo>
175 </target>
176
177 <target name="del-webswing-for-tomcat" description="Helper-target to remove files for getting webswing to work with tomcat">
178 <!-- Actually need to ensure tomcat is not running at this point
179 But if webswing-server.war is deleted first, it can't be re-deployed when deleting the webswing folder subsequently
180 -->
181 <echo/>
182 <echo>Removing webswing webapp installed to tomcat</echo>
183 <delete failonerror="false" file="${tomcat.dir}/webapps/${webswing.context}.war"/>
184 <delete failonerror="false" includeEmptyDirs="true" dir="${tomcat.dir}/webapps/${webswing.context}"/>
185 </target>
186
187 <target name="del-extension" depends="accept-del-extension,del-etc-files,del-webswing-for-tomcat"
188 description="Run this target to remove the Webswing extension for Greenstone3" />
189
190</project>
Note: See TracBrowser for help on using the repository browser.