source: other-projects/gs3-webservices-java-client/trunk/build.xml@ 21525

Last change on this file since 21525 was 21525, checked in by ak19, 13 years ago

SVN urls to gs3 and gli have changed and needed to be adjusted in build.xml to reflect their new locations

File size: 15.6 KB
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
7 for info on build.xml ant files,
8 and
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>
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" />
23 <property name="build" value="${basedir}/build" />
24 <property name="dist" value="${basedir}/dist" />
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" />
31 <property 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="" />
35 <property name="" value="gs3_webservices_democlient" />
36 <property name="zip.excludes" value="dist/**,logs/**," />
37 <property name="" value="gs3-webservices-democlient" />
39 <!-- svn url locations for obtaining copies of the latest version of source code dependencies -->
40 <property name="gs3forclient.svn.path" value=""/>
41 <property name="" value=""/>
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>
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 make-dist</echo>
61 <echo> for generating the zip/gzip/bzip file of the project</echo>
62 <echo>- ant clean-democlient</echo>
63 <echo> for deleting the *.class files from the GS3democlient's source</echo>
64 <echo>- ant clean</echo>
65 <echo> for deleting the *.class files from the GS3democlient and GS3Fedora sources</echo>
66 <echo>- ant dist-clean</echo>
67 <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>
68 <echo>- ant update</echo>
69 <echo> for getting the latest version of, and the files for creating the gs3_for_client.jar dependency from Greenstone's SVN repository</echo>
70 <echo>- ant GSearchInstallerjar</echo>
71 <echo> for generating the GSearchInstaller.jar application that helps in installing Fedora Generic Search (if you have Fedora installed).</echo>
75<!-- Main targets: to build the GS3 web services demo-client and to create the tar.gz file for downloading -->
76<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client,ensure-check-java-version">
77 <mkdir dir="${basedir}/logs" /> <!-- Need a logs dir for outputting log4j stuff-->
78 <jar destfile="${}"
79 basedir="${democlient.rootdir}/"
80 manifest="Manifest.MF"
81 excludes="${QBRdata.rel.path}/*.class"
82 />
83 <copy file="${src.dir}/${log4j.propFile}" tofile="${basedir}/${log4j.propFile}"/>
84<!-- LATER: only for tarring include source files, so that we can exclude the java files in this build?-->
87<target name="make-dist" description="Generates the zip file of the lib and src folders and the executable ${} file" depends="get-zipformat,ensure-exec-jar,ensure-gsearchinstall-jar" if="zip.type">
88 <mkdir dir="${dist}" />
89 <antcall target="create-${zip.type}"/>
92<!-- 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.-->
93<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar,ensure-gs3-for-client">
94 <javac srcdir="${democlient.rootdir}">
95 <classpath refid="project.classpath"/>
96 <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-->
97 </javac>
100<!-- Cleaning targets -->
101<target name="clean-democlient" description="Removes all class files from the GS3demo-client (includes the data package that is used to create QBRdata.jar)">
102 <delete>
103 <fileset dir="${democlient.src}" includes="**/*.class"/>
104 </delete>
107<target name="clean" description="Removes all class files from the GS3DemoClient, GS3Fedora, GSearchInstaller source folders" depends="clean-democlient">
108 <delete>
109 <fileset dir="${fedorags3.src}" includes="**/*.class"/>
110 <fileset dir="${gsearchinstaller.src}" includes="**/*.class"/>
111 </delete>
114<target name="dist-clean" description="Removes the project-specific jars fedoraGS3.jar, QBRdata.jar, ${} files AND all class files from the GS3DemoClient, GS3Fedora and GSearchInstaller source folders" depends="clean">
115 <delete includeEmptyDirs="true" failonerror="false">
116 <fileset file="${basedir}/GSearchInstaller.jar"/>
117 <fileset file="${basedir}/lib/fedoraGS3.jar"/>
118 <fileset file="${basedir}/lib/QBRdata.jar"/>
119 <fileset file="${basedir}/${}"/>
120 <fileset file="${basedir}/"/>
121 <fileset dir="logs"/>
122 <fileset file="${log4j.propFile}"/>
123 <fileset file="${dist}/${}.tar"/>
124 <fileset file="${dist}/${}.tar.gz"/>
125 <fileset file="${dist}/${}.zip"/>
126 <fileset file="${dist}/${}.tar.bz2"/>
127 </delete>
130<!-- Targets for updating some source code dependencies from Greenstone SVN -->
131<!-- Explicit update of java file dependencies. First make a directory and copy the old files in there (if they are present)-->
132<target name="update" description="Gets the latest version of, and gs3-client-jar's files from Greenstone's SVN repository">
133 <delete>
134 <fileset dir="${basedir}" includes="CheckJavaVersion.*"/>
135 </delete>
136 <antcall target="update-check-java-version" />
137 <antcall target="update-gs3-for-client" />
140<target name="ensure-gs3-for-client" description="Ensures the ${gs3.files.jar} file of required Greenstone3 support files is there">
141 <condition property="gs3.for.client.exists">
142 <available file="${basedir}/lib/${gs3.files.jar}"/>
143 </condition>
144 <antcall target="update-gs3-for-client" />
147<target name="ensure-check-java-version" description="Ensures the file required to run the demo-client's launching scripts (sh or bat) is present">
148 <condition property="">
149 <and>
150 <available file="${basedir}/CheckJavaVersion.class"/>
151 <available file="${basedir}/"/>
152 </and>
153 </condition>
154 <antcall target="update-check-java-version" />
157<!-- Gets the file if the local copy is missing or out of date (since usetimestamp=true) -->
158<target name="update-check-java-version" description="Gets the latest version of from Greenstone's SVN repository" unless="">
159 <get src="${}"
160 dest="${basedir}/"
161 usetimestamp="true" />
162 <!-- compile it up: specifying the file to be compiled explicitly (sourcepath="")-->
163 <javac sourcepath="" srcdir="${basedir}" destdir="${basedir}" >
164 <include name="**/"/>
165 </javac>
168<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">
169 <mkdir dir="${basedir}/tmp" />
170 <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>
171 <!-- 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 -->
172 <get src="${gs3forclient.svn.path}/" dest="${basedir}/tmp/" />
173 <get src="${gs3forclient.svn.path}/" dest="${basedir}/tmp/" />
174 <get src="${gs3forclient.svn.path}/" dest="${basedir}/tmp/" />
175 <get src="${gs3forclient.svn.path}/" dest="${basedir}/tmp/" />
176 <!-- compile it up: specifying the file to be compiled explicitly -->
177 <javac srcdir="${basedir}/tmp" destdir="${basedir}/tmp" >
178 <classpath refid="project.classpath"/>
179 <include name="**/*.java"/>
180 </javac>
181 <!-- jar it up (without the java files), placing the jar in the lib folder -->
182 <jar destfile="lib/${gs3.files.jar}" basedir="tmp/" excludes="tmp/*.java" />
183 <delete dir="tmp" />
186<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
187<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
188 <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}">
189 <classpath refid="project.classpath"/>
190 </javac>
191 <jar destfile="lib/QBRdata.jar"
192 basedir="${democlient.rootdir}/"
193 excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
194 </jar>
197<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
198 <javac srcdir="${fedorags3.rootdir}">
199 <classpath refid="project.classpath"/>
200 </javac>
201 <jar destfile="lib/fedoraGS3.jar"
202 basedir="${fedorags3.rootdir}/"/>
205<!-- Target that generates the GSearchInstaller jar file -->
206<target name="GSearchInstallerjar" description="Compiles and creates the jar file for the stand-alone GSearchInstaller application">
207 <javac srcdir="${gsearchinstaller.rootdir}"/>
208 <jar destfile="GSearchInstaller.jar"
209 basedir="${gsearchinstaller.rootdir}/"
210 manifest="${gsearchinstaller.rootdir}/Manifest.MF"/>
213<!-- Targets that check for and ensure the existence of project-specific jar files -->
214<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
215 <condition property="QBRdata.exists">
216 <available file="${basedir}/lib/QBRdata.jar"/>
217 </condition>
220<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
221 <antcall target="QBRdatajar"/>
224<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
225 <condition property="fedoraGS3.exists">
226 <available file="${basedir}/lib/fedoraGS3.jar"/>
227 </condition>
230<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
231 <antcall target="fedoraGS3jar"/>
234<!-- generates the project's executable -->
235<target name="check-exec-jar" description="Checks for existence of executable file ${}">
236 <condition property="executable.exists">
237 <available file="${basedir}/${}"/>
238 </condition>
241<target name="ensure-exec-jar" description="Will generate ${} if it did not exist" depends="check-exec-jar" unless="executable.exists">
242 <antcall target="build-demo-client"/>
245<!-- Targets that check for and ensure the existence of standalone application GSearchInstaller.jar -->
246<target name="check-gsearchinstall-jar" description="Checks for existence of stand-alone application GSearchInstaller.jar">
247 <condition property="gsearchinstaller.exists">
248 <available file="GSearchInstaller.jar"/>
249 </condition>
252<target name="ensure-gsearchinstall-jar" description="Will generate GSearchInstaller.jar if it did not exist" depends="check-gsearchinstall-jar" unless="gsearchinstaller.exists">
253 <antcall target="GSearchInstallerjar"/>
256<!-- 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)-->
257<target name="create-targzip" if="zip.type" description="User chose to create a tar.gz file of the project">
258 <tar destfile="${dist}/${}.tar.gz" compression="gzip" longfile="gnu">
259 <tarfileset dir="${basedir}" prefix="${}" excludes="${zip.excludes}" />
260 </tar>
261 <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
264<target name="create-tarbzip" if="zip.type" description="User chose to create a tar.bz2 file of the project">
265 <tar destfile="${dist}/${}.tar.bz2" compression="bzip2" longfile="gnu">
266 <tarfileset dir="${basedir}" prefix="${}" excludes="${zip.excludes}" />
267 </tar>
268 <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
271<target name="create-zip" if="zip.type" description="User chose to create a zip file of the project">
272 <zip destfile="${dist}/${}.zip">
273 <zipfileset dir="${basedir}" prefix="${}" excludes="${zip.excludes}" />
274 </zip>
277<target name="get-zipformat">
278<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
279 <input addproperty="zip.format" defaultvalue="zip">What type of compressed output file do you want to generate?
280Type one of: zip, tar.gz, tar.bz2
281Press enter for default: zip /></input>
282 <condition property="zip.type" value="targzip">
283 <equals arg1="tar.gz" arg2="${zip.format}"/>
284 </condition>
285 <condition property="zip.type" value="zip">
286 <equals arg1="zip" arg2="${zip.format}"/>
287 </condition>
288 <condition property="zip.type" value="tarbzip">
289 <equals arg1="tar.bz2" arg2="${zip.format}"/>
290 </condition>
291 <echo>You chose output file type: ${zip.type}</echo>
292 </target>
Note: See TracBrowser for help on using the repository browser.