root/other-projects/gs3-webservices-java-client/trunk/build.xml @ 32392

Revision 26270, 17.4 KB (checked in by ak19, 7 years ago)

1. Now checks request for nodeStructureInfo documentType, as is needed to get it working with GS3 again. 2. Added in reusable constants of gsdl3/util/AbstractBasicDocument.java since these have now been made public constants.

Line 
1<?xml version="1.0"?>
2<!-- ======================================================================
3     April 2008 - GS3 web services democlient compile script
4     With lots of help from kjdon's Greenstone3 build and install script
5     See http://ant.apache.org/manual/
6     http://ant.apache.org/manual/usinglist.html
7     for info on build.xml ant files,                                                         
8     and http://ant.apache.org/manual/coretasklist.html
9     http://ant.apache.org/manual/tasksoverview.html
10====================================================================== -->
11<project name="gs3democlient" default="usage" basedir=".">
12<description>This buildfile is used to build the demo-client for Greenstone3's web services.</description>
13
14  <!-- ============ predefining properties for reuse =================== -->
15 <property name="src.dir" value="${basedir}/src" />
16 <property name="democlient.rootdir" value="${src.dir}/GS3DemoClient" />
17 <property name="democlient.src" value="${democlient.rootdir}/org" />
18 <property name="fedorags3.rootdir" value="${src.dir}/GS3Fedora" />
19 <property name="fedorags3.src" value="${fedorags3.rootdir}/org" />
20 <property name="gsearchinstaller.rootdir" value="${src.dir}/GSearchInstaller" />
21 <property name="gsearchinstaller.src" value="${gsearchinstaller.rootdir}/org" />
22
23 <property name="build" value="${basedir}/build" />
24 <property name="dist" value="${basedir}/dist" />
25
26 <property name="QBRdata.rel.path" value="org/greenstone/gs3client/data" />
27 <property name="dlservices.rel.path" value="org/greenstone/gs3client/dlservices" />
28 <property name="gui.rel.path" value="org/greenstone/gs3client" />
29 <property name="gs3services.rel.path" value="org/greenstone/gs3services" />
30
31 <property name="exec.jar.name" value="GS3democlient.jar" /> <!-- name of the executable-->
32 <property name="gs3.files.jar" value="gs3_for_client.jar" />
33 <property name="log4j.propFile" value="log4j.properties" />
34
35 <property name="dist.zip.name" value="gs3_webservices_democlient" />
36 <property name="zip.excludes" value="dist/**,logs/**,gs3democlient.properties" />
37 <property name="dist.dir.name" value="gs3-webservices-democlient" />
38
39 <!-- svn url locations for obtaining copies of the latest version of source code dependencies -->
40 <property name="gs3forclient.svn.path" value="http://svn.greenstone.org/main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util"/>
41 <property name="check.java.version.svn.file" value="http://svn.greenstone.org/main/trunk/gli/CheckJavaVersion.java"/>
42
43  <!-- ============ project classpath: everything in the lib folder =================== -->
44 <path id="project.classpath">
45     <fileset dir="lib">
46      <include name="**/*.jar"/>
47    </fileset>
48  </path>
49
50<target name="usage" description="Prints out ant commands for the GS3 demo-client">
51    <echo>Type:</echo>
52    <echo>- ant build-demo-client</echo>
53    <echo>  for (compiling) and creating the demo-client executable</echo>
54    <echo>- ant compile-demo-client</echo>
55    <echo>  for compiling the democlient</echo>
56    <echo>- ant fedoraGS3jar</echo>
57    <echo>  for generating the fedoraGS3.jar dependency file</echo>
58    <echo>- ant QBRdatajar</echo>
59    <echo>  for generating the QBRdata.jar dependency file</echo>
60        <echo>- ant DLservicesjar</echo>
61    <echo>  for generating the DLservices.jar standalone library</echo>
62    <echo>- ant make-dist</echo>
63    <echo>  for generating the zip/gzip/bzip file of the project</echo>
64    <echo>- ant clean-democlient</echo>
65    <echo>  for deleting the *.class files from the GS3democlient's source</echo>
66    <echo>- ant clean</echo>
67    <echo>  for deleting the *.class files from the GS3democlient and GS3Fedora sources</echo>
68    <echo>- ant distclean</echo>
69    <echo>  for deleting the *.class files from the sources, the QBRdata.jar, fedoraGS3.jar, executable jar file, and any zips of the project folder</echo>
70        <echo>- ant update</echo>
71        <echo>  for getting the latest version of CheckJavaVersion.java, and the files for creating the gs3_for_client.jar dependency from Greenstone's SVN repository</echo>
72    <echo>- ant GSearchInstallerjar</echo>
73        <echo>  for generating the GSearchInstaller.jar application that helps in installing Fedora Generic Search (if you have Fedora installed).</echo>
74</target>
75
76
77<!-- Main targets: to build the GS3 web services demo-client and to create the tar.gz file for downloading -->
78<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client,ensure-check-java-version">
79  <mkdir dir="${basedir}/logs" /> <!-- Need a logs dir for outputting log4j stuff-->
80  <jar destfile="${exec.jar.name}"
81     basedir="${democlient.rootdir}/"
82     manifest="Manifest.MF"
83     excludes="${QBRdata.rel.path}/*.class"
84  />
85  <copy file="${src.dir}/${log4j.propFile}" tofile="${basedir}/${log4j.propFile}"/>
86<!-- LATER: only for tarring include source files, so that we can exclude the java files in this build?-->
87</target>
88
89<target name="make-dist" description="Generates the zip file of the lib and src folders and the executable ${exec.jar.name} file" depends="get-zipformat,ensure-exec-jar,ensure-gsearchinstall-jar" if="zip.type">
90   <mkdir dir="${dist}" />
91   <antcall target="create-${zip.type}"/>
92</target>
93
94<!--
95http://ananthkannan.blogspot.com/2009/12/java-exception-unknown-source.html
96"Sometimes when debugging application we may run into this exception - Java Exception unknown source.
97The possible reason could be when compiling the application, javac ant tasks omits debug option by defaut. So we will have to explicity set debug flag to true. See the javac ant task documentation for more info. You can mention some thing like below:
98
99<target name="compile">
100  <javac srcdir="${src.dir}" destdir="{dest.dir}." debug="on" debuglevel="lines,vars,source" />
101</target>"
102-->
103
104<!-- Compilation first ensures the existence of QBRdata.jar AND fedoraGS3.jar by checking whether these jars already exist and, if not, generating them. It is then that the actual compilation of the GS3democlient starts. By now the QBRdata classes of the GS3democlient src folder would have been compiled, but that does not matter as javac only compiles when class files are outdated or when they have not been generated yet.-->
105<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar,ensure-gs3-for-client">
106    <javac srcdir="${democlient.rootdir}" debug="on" debuglevel="lines,vars,source">
107      <classpath refid="project.classpath"/>
108      <exclude name="${gs3services.rel.path}/**" /> <!--gs3services package needs official gsdl.jar to compile, so we skip it as it is not part of the client anyway-->
109    </javac>
110</target>
111
112<!-- Cleaning targets -->
113<target name="clean-democlient" description="Removes all class files from the GS3demo-client (includes the data package that is used to create QBRdata.jar)">
114   <delete>
115    <fileset dir="${democlient.src}" includes="**/*.class"/>
116   </delete>
117</target>
118
119<target name="clean" description="Removes all class files from the GS3DemoClient, GS3Fedora, GSearchInstaller source folders" depends="clean-democlient">
120   <delete>
121    <fileset dir="${fedorags3.src}" includes="**/*.class"/>
122    <fileset dir="${gsearchinstaller.src}" includes="**/*.class"/>
123   </delete>
124</target>
125
126<target name="distclean" description="Removes the project-specific jars fedoraGS3.jar, QBRdata.jar, ${exec.jar.name} files AND all class files from the GS3DemoClient, GS3Fedora and GSearchInstaller source folders" depends="clean">
127   <delete includeEmptyDirs="true" failonerror="false">
128    <fileset file="${basedir}/GSearchInstaller.jar"/>
129    <fileset file="${basedir}/lib/fedoraGS3.jar"/>
130    <fileset file="${basedir}/lib/QBRdata.jar"/>
131    <fileset file="${basedir}/lib/DLservices.jar"/>
132    <fileset file="${basedir}/${exec.jar.name}"/>
133    <fileset file="${basedir}/gs3democlient.properties"/>
134    <fileset dir="logs"/>
135    <fileset file="${log4j.propFile}"/>
136    <fileset file="${dist}/${dist.zip.name}.tar"/>
137    <fileset file="${dist}/${dist.zip.name}.tar.gz"/>
138    <fileset file="${dist}/${dist.zip.name}.zip"/>
139    <fileset file="${dist}/${dist.zip.name}.tar.bz2"/>
140   </delete>
141</target>
142
143<!-- Targets for updating some source code dependencies from Greenstone SVN -->
144<!-- Explicit update of java file dependencies. First make a directory and copy the old files in there (if they are present)-->
145<target name="update" description="Gets the latest version of CheckJavaVersion.java, and gs3-client-jar's files from Greenstone's SVN repository">
146   <delete>
147      <fileset dir="${basedir}" includes="CheckJavaVersion.*"/>
148   </delete>
149   <antcall target="update-check-java-version" />   
150   <antcall target="update-gs3-for-client" />
151</target>
152
153<target name="ensure-gs3-for-client" description="Ensures the ${gs3.files.jar} file of required Greenstone3 support files is there">
154    <condition property="gs3.for.client.exists">
155    <available file="${basedir}/lib/${gs3.files.jar}"/>
156    </condition>
157    <antcall target="update-gs3-for-client" />
158</target>
159
160<target name="ensure-check-java-version" description="Ensures the CheckJavaVersion.java file required to run the demo-client's launching scripts (sh or bat) is present">
161    <condition property="check.java.version.exists">
162    <and>
163    <available file="${basedir}/CheckJavaVersion.class"/>
164    <available file="${basedir}/CheckJavaVersion.java"/>
165    </and>
166    </condition>
167    <antcall target="update-check-java-version" />
168</target>
169
170<!-- Gets the file if the local copy is missing or out of date (since usetimestamp=true) -->
171<target name="update-check-java-version" description="Gets the latest version of CheckJavaVersion.java from Greenstone's SVN repository" unless="check.java.version.exists">
172  <get src="${check.java.version.svn.file}"
173    dest="${basedir}/CheckJavaVersion.java"
174    usetimestamp="true" />
175  <!-- compile it up: specifying the file to be compiled explicitly (sourcepath="")-->
176  <javac sourcepath="" srcdir="${basedir}" destdir="${basedir}" debug="on" debuglevel="lines,vars,source">
177    <include name="**/CheckJavaVersion.java"/>
178  </javac>
179</target>
180
181<target name="update-gs3-for-client" description="Gets the latest version of the files needed to create ${gs3.files.jar} from Greenstone's SVN repository" unless="gs3.for.client.exists">
182  <mkdir dir="${basedir}/tmp" />
183  <echo>Getting java files GSXML, XMLConverter, GSPath and MyNodeList from Greenstone's SVN repository (${gs3forclient.svn.path}). Compiling and jarring them up into ${gs3.files.jar}...</echo>
184  <!-- No point using timestamp here with the get Task, since the tmp file is newly created and will not already have these java files. Get will therefore always retrieve them.
185AbstractBasicDocument.java is included for defining constants for the possible NodeStructureInfo param values. -->
186  <get src="${gs3forclient.svn.path}/UserContext.java" dest="${basedir}/tmp/UserContext.java" />
187  <get src="${gs3forclient.svn.path}/GSXML.java" dest="${basedir}/tmp/GSXML.java" />
188  <get src="${gs3forclient.svn.path}/XMLConverter.java" dest="${basedir}/tmp/XMLConverter.java" />
189  <get src="${gs3forclient.svn.path}/GSPath.java" dest="${basedir}/tmp/GSPath.java" />
190  <get src="${gs3forclient.svn.path}/MyNodeList.java" dest="${basedir}/tmp/MyNodeList.java" />
191  <get src="${gs3forclient.svn.path}/AbstractBasicDocument.java" dest="${basedir}/tmp/AbstractBasicDocument.java" />
192  <!-- compile it up: specifying the file to be compiled explicitly -->
193  <javac srcdir="${basedir}/tmp" destdir="${basedir}/tmp" debug="on" debuglevel="lines,vars,source">
194    <classpath refid="project.classpath"/>
195    <include name="**/*.java"/>
196  </javac> 
197  <!-- jar it up (without the java files), placing the jar in the lib folder -->   
198  <jar destfile="lib/${gs3.files.jar}" basedir="tmp/" excludes="tmp/*.java" />
199  <delete dir="tmp" />
200</target>
201
202<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
203<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
204   <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}" debug="on" debuglevel="lines,vars,source">
205      <classpath refid="project.classpath"/>
206   </javac>
207   <jar destfile="lib/QBRdata.jar"
208     basedir="${democlient.rootdir}/"
209     excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
210   </jar>
211</target>
212
213<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
214   <javac srcdir="${fedorags3.rootdir}" debug="on" debuglevel="lines,vars,source">
215      <classpath refid="project.classpath"/>
216   </javac>
217   <jar destfile="lib/fedoraGS3.jar"
218     basedir="${fedorags3.rootdir}/"/>
219</target>
220
221<!-- Target to generate the standalone (reusable) jar files DLservices.jar -->
222<target name="DLservicesjar" description="Compiles and creates the DLservices.jar standalone, reusable library file">
223   <javac srcdir="${democlient.rootdir}/${dlservices.rel.path}" debug="on" debuglevel="lines,vars,source">
224      <classpath refid="project.classpath"/>
225   </javac>
226   <jar destfile="lib/DLservices.jar"
227     basedir="${democlient.rootdir}/"
228     excludes="${gui.rel.path}/*.*,${QBRdata.rel.path}/**,${gs3services.rel.path}/**">
229   </jar>
230</target>
231
232<!-- Target that generates the GSearchInstaller jar file -->
233<target name="GSearchInstallerjar" description="Compiles and creates the jar file for the stand-alone GSearchInstaller application">
234   <javac srcdir="${gsearchinstaller.rootdir}" debug="on" debuglevel="lines,vars,source" />
235   <jar destfile="GSearchInstaller.jar"
236     basedir="${gsearchinstaller.rootdir}/"
237     manifest="${gsearchinstaller.rootdir}/Manifest.MF"/>
238</target>
239
240<!-- Targets that check for and ensure the existence of project-specific jar files -->
241<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
242    <condition property="QBRdata.exists">
243    <available file="${basedir}/lib/QBRdata.jar"/>
244    </condition>
245</target>
246
247<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
248    <antcall target="QBRdatajar"/>
249</target>
250
251<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
252    <condition property="fedoraGS3.exists">
253    <available file="${basedir}/lib/fedoraGS3.jar"/>
254    </condition>
255</target>
256
257<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
258    <antcall target="fedoraGS3jar"/>
259</target>
260
261<!-- generates the project's executable -->
262<target name="check-exec-jar" description="Checks for existence of executable file ${exec.jar.name}">
263    <condition property="executable.exists">
264    <available file="${basedir}/${exec.jar.name}"/>
265    </condition>
266</target>
267
268<target name="ensure-exec-jar" description="Will generate ${exec.jar.name} if it did not exist" depends="check-exec-jar" unless="executable.exists">
269    <antcall target="build-demo-client"/>
270</target>
271
272<!-- Targets that check for and ensure the existence of standalone application GSearchInstaller.jar -->
273<target name="check-gsearchinstall-jar" description="Checks for existence of stand-alone application GSearchInstaller.jar">
274    <condition property="gsearchinstaller.exists">
275    <available file="GSearchInstaller.jar"/>
276    </condition>
277</target>
278
279<target name="ensure-gsearchinstall-jar" description="Will generate GSearchInstaller.jar if it did not exist" depends="check-gsearchinstall-jar" unless="gsearchinstaller.exists">
280    <antcall target="GSearchInstallerjar"/>
281</target>
282
283<!-- User input for generating compressed output file for one of the chosen file types. A choice of zip, tar.gz (tar gzip), or tar.bz2 (tar bzip)-->
284<target name="create-targzip" if="zip.type" description="User chose to create a tar.gz file of the project">
285   <tar destfile="${dist}/${dist.zip.name}.tar.gz" compression="gzip" longfile="gnu">
286     <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
287   </tar>
288   <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
289</target>
290
291<target name="create-tarbzip" if="zip.type" description="User chose to create a tar.bz2 file of the project">
292    <tar destfile="${dist}/${dist.zip.name}.tar.bz2" compression="bzip2" longfile="gnu">
293      <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
294    </tar>
295    <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
296</target>
297
298<target name="create-zip" if="zip.type" description="User chose to create a zip file of the project">
299    <zip destfile="${dist}/${dist.zip.name}.zip">
300       <zipfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
301    </zip>
302</target>
303
304<target name="get-zipformat"> 
305<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
306    <input addproperty="zip.format" defaultvalue="zip">What type of compressed output file do you want to generate?
307Type one of: zip, tar.gz, tar.bz2
308Press enter for default: zip /></input>
309    <condition property="zip.type" value="targzip">
310      <equals arg1="tar.gz" arg2="${zip.format}"/>
311    </condition>
312    <condition property="zip.type" value="zip">
313      <equals arg1="zip" arg2="${zip.format}"/>
314    </condition>
315    <condition property="zip.type" value="tarbzip">
316      <equals arg1="tar.bz2" arg2="${zip.format}"/>
317    </condition>
318    <echo>You chose output file type: ${zip.type}</echo>
319  </target>
320</project>
Note: See TracBrowser for help on using the browser.