source: other-projects/trunk/gs3-webservices-democlient/build.xml@ 15734

Last change on this file since 15734 was 15734, checked in by ak19, 16 years ago

Removed jar-file delete commands since these commands cause the build to fail on Windows. Jar file generation is set to overwrite any existing jar of the same name by default anyway.

File size: 14.1 KB
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="fedorags3.rootdir" value="${src.dir}/GS3Fedora" />
18 <property name="democlient.src" value="${democlient.rootdir}/org" />
19 <property name="fedorags3.src" value="${fedorags3.rootdir}/org" />
20 <property name="build" value="${basedir}/build" />
21 <property name="dist" value="${basedir}/dist" />
22
23 <property name="QBRdata.rel.path" value="org/greenstone/gs3client/data" />
24 <property name="dlservices.rel.path" value="org/greenstone/gs3client/dlservices" />
25 <property name="gui.rel.path" value="org/greenstone/gs3client" />
26 <property name="gs3services.rel.path" value="org/greenstone/gs3services" />
27
28 <property name="exec.jar.name" value="GS3democlient.jar" /> <!-- name of the executable-->
29 <property name="gs3.files.jar" value="gs3_for_client.jar" />
30 <property name="log4j.propFile" value="log4j.properties" />
31
32 <property name="dist.zip.name" value="gs3_webservices_democlient" />
33 <property name="zip.excludes" value="dist/**,logs/**,gs3democlient.properties" />
34 <property name="dist.dir.name" value="gs3-webservices-democlient" />
35
36 <!-- svn url locations for obtaining copies of the latest version of source code dependencies -->
37 <property name="gs3forclient.svn.path" value="http://svn.greenstone.org/greenstone3/trunk/src/java/org/greenstone/gsdl3/util"/>
38 <property name="check.java.version.svn.file" value="http://svn.greenstone.org/gli/trunk/CheckJavaVersion.java"/>
39
40 <!-- ============ project classpath: everything in the lib folder =================== -->
41 <path id="project.classpath">
42 <fileset dir="lib">
43 <include name="**/*.jar"/>
44 </fileset>
45 </path>
46
47<target name="usage" description="Prints out ant commands for the GS3 demo-client">
48 <echo>Type:</echo>
49 <echo>- ant build-demo-client</echo>
50 <echo> for (compiling) and creating the demo-client executable</echo>
51 <echo>- ant compile-demo-client</echo>
52 <echo> for compiling the democlient</echo>
53 <echo>- ant fedoraGS3jar</echo>
54 <echo> for generating the fedoraGS3.jar dependency file</echo>
55 <echo>- ant QBRdatajar</echo>
56 <echo> for generating the QBRdata.jar dependency file</echo>
57 <echo>- ant make-dist</echo>
58 <echo> for generating the zip/gzip/bzip file of the project</echo>
59 <echo>- ant clean-democlient</echo>
60 <echo> for deleting the *.class files from the GS3democlient's source</echo>
61 <echo>- ant clean</echo>
62 <echo> for deleting the *.class files from the GS3democlient and GS3Fedora sources</echo>
63 <echo>- ant dist-clean</echo>
64 <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>
65 <echo>- ant update</echo>
66 <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>
67</target>
68
69
70<!-- Main targets: to build the GS3 web services demo-client and to create the tar.gz file for downloading -->
71<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client,ensure-check-java-version">
72 <mkdir dir="${basedir}/logs" /> <!-- Need a logs dir for outputting log4j stuff-->
73 <jar destfile="${exec.jar.name}"
74 basedir="${democlient.rootdir}/"
75 manifest="Manifest.MF"
76 excludes="${QBRdata.rel.path}/*.class"
77 />
78 <copy file="${src.dir}/${log4j.propFile}" tofile="${basedir}/${log4j.propFile}"/>
79<!-- LATER: only for tarring include source files, so that we can exclude the java files in this build?-->
80</target>
81
82<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" if="zip.type">
83 <mkdir dir="${dist}" />
84 <antcall target="create-${zip.type}"/>
85</target>
86
87<!-- 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.-->
88<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar,ensure-gs3-for-client">
89 <javac srcdir="${democlient.rootdir}">
90 <classpath refid="project.classpath"/>
91 <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-->
92 </javac>
93</target>
94
95<!-- Cleaning targets -->
96<target name="clean-democlient" description="Removes all class files from the GS3demo-client (includes the data package that is used to create QBRdata.jar)">
97 <delete>
98 <fileset dir="${democlient.src}" includes="**/*.class"/>
99 </delete>
100</target>
101
102<target name="clean" description="Removes all class files from the GS3DemoClient and GS3Fedora source folders" depends="clean-democlient">
103 <delete>
104 <fileset dir="${fedorags3.src}" includes="**/*.class"/>
105 </delete>
106</target>
107
108<target name="dist-clean" description="Removes the project-specific jars fedoraGS3.jar, QBRdata.jar, ${exec.jar.name} files AND all class files from the GS3DemoClient and GS3Fedora source folders" depends="clean">
109 <delete includeEmptyDirs="true" failonerror="false">
110 <fileset file="${basedir}/lib/fedoraGS3.jar"/>
111 <fileset file="${basedir}/lib/QBRdata.jar"/>
112 <fileset file="${basedir}/${exec.jar.name}"/>
113 <fileset file="${basedir}/gs3democlient.properties"/>
114 <fileset dir="logs"/>
115 <fileset file="${log4j.propFile}"/>
116 <fileset file="${dist}/${dist.zip.name}.tar"/>
117 <fileset file="${dist}/${dist.zip.name}.tar.gz"/>
118 <fileset file="${dist}/${dist.zip.name}.zip"/>
119 <fileset file="${dist}/${dist.zip.name}.tar.bz2"/>
120 </delete>
121</target>
122
123<!-- Targets for updating some source code dependencies from Greenstone SVN -->
124<!-- Explicit update of java file dependencies. First make a directory and copy the old files in there (if they are present)-->
125<target name="update" description="Gets the latest version of CheckJavaVersion.java, and gs3-client-jar's files from Greenstone's SVN repository">
126 <delete>
127 <fileset dir="${basedir}" includes="CheckJavaVersion.*"/>
128 </delete>
129 <antcall target="update-check-java-version" />
130 <antcall target="update-gs3-for-client" />
131</target>
132
133<target name="ensure-gs3-for-client" description="Ensures the ${gs3.files.jar} file of required Greenstone3 support files is there">
134 <condition property="gs3.for.client.exists">
135 <available file="${basedir}/lib/${gs3.files.jar}"/>
136 </condition>
137 <antcall target="update-gs3-for-client" />
138</target>
139
140<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">
141 <condition property="check.java.version.exists">
142 <and>
143 <available file="${basedir}/CheckJavaVersion.class"/>
144 <available file="${basedir}/CheckJavaVersion.java"/>
145 </and>
146 </condition>
147 <antcall target="update-check-java-version" />
148</target>
149
150<!-- Gets the file if the local copy is missing or out of date (since usetimestamp=true) -->
151<target name="update-check-java-version" description="Gets the latest version of CheckJavaVersion.java from Greenstone's SVN repository" unless="check.java.version.exists">
152 <get src="${check.java.version.svn.file}"
153 dest="${basedir}/CheckJavaVersion.java"
154 usetimestamp="true" />
155 <!-- compile it up: specifying the file to be compiled explicitly (sourcepath="")-->
156 <javac sourcepath="" srcdir="${basedir}" destdir="${basedir}" >
157 <include name="**/CheckJavaVersion.java"/>
158 </javac>
159</target>
160
161<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">
162 <mkdir dir="${basedir}/tmp" />
163 <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>
164 <!-- 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 -->
165 <get src="${gs3forclient.svn.path}/GSXML.java" dest="${basedir}/tmp/GSXML.java" />
166 <get src="${gs3forclient.svn.path}/XMLConverter.java" dest="${basedir}/tmp/XMLConverter.java" />
167 <get src="${gs3forclient.svn.path}/GSPath.java" dest="${basedir}/tmp/GSPath.java" />
168 <get src="${gs3forclient.svn.path}/MyNodeList.java" dest="${basedir}/tmp/MyNodeList.java" />
169 <!-- compile it up: specifying the file to be compiled explicitly -->
170 <javac srcdir="${basedir}/tmp" destdir="${basedir}/tmp" >
171 <classpath refid="project.classpath"/>
172 <include name="**/*.java"/>
173 </javac>
174 <!-- jar it up (without the java files), placing the jar in the lib folder -->
175 <jar destfile="lib/${gs3.files.jar}" basedir="tmp/" excludes="tmp/*.java" />
176 <delete dir="tmp" />
177</target>
178
179<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
180<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
181 <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}">
182 <classpath refid="project.classpath"/>
183 </javac>
184 <jar destfile="lib/QBRdata.jar"
185 basedir="${democlient.rootdir}/"
186 excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
187 </jar>
188</target>
189
190<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
191 <javac srcdir="${fedorags3.rootdir}">
192 <classpath refid="project.classpath"/>
193 </javac>
194 <jar destfile="lib/fedoraGS3.jar"
195 basedir="${fedorags3.rootdir}/"/>
196</target>
197
198<!-- Targets that check for and ensure the existence of project-specific jar files -->
199<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
200 <condition property="QBRdata.exists">
201 <available file="${basedir}/lib/QBRdata.jar"/>
202 </condition>
203</target>
204
205<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
206 <antcall target="QBRdatajar"/>
207</target>
208
209<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
210 <condition property="fedoraGS3.exists">
211 <available file="${basedir}/lib/fedoraGS3.jar"/>
212 </condition>
213</target>
214
215<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
216 <antcall target="fedoraGS3jar"/>
217</target>
218
219<!-- generates the project's executable -->
220<target name="check-exec-jar" description="Checks for existence of executable file ${exec.jar.name}">
221 <condition property="executable.exists">
222 <available file="${basedir}/${exec.jar.name}"/>
223 </condition>
224</target>
225
226<target name="ensure-exec-jar" description="Will generate ${exec.jar.name} if it did not exist" depends="check-exec-jar" unless="executable.exists">
227 <antcall target="build-demo-client"/>
228</target>
229
230<!-- 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)-->
231<target name="create-targzip" if="zip.type" description="User chose to create a tar.gz file of the project">
232 <tar destfile="${dist}/${dist.zip.name}.tar.gz" compression="gzip" longfile="gnu">
233 <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
234 </tar>
235 <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
236</target>
237
238<target name="create-tarbzip" if="zip.type" description="User chose to create a tar.bz2 file of the project">
239 <tar destfile="${dist}/${dist.zip.name}.tar.bz2" compression="bzip2" longfile="gnu">
240 <tarfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
241 </tar>
242 <echo>If the filepaths are longer than 100 characters, GNU compatible tar commands are necessary to untar the tar.gz</echo>
243</target>
244
245<target name="create-zip" if="zip.type" description="User chose to create a zip file of the project">
246 <zip destfile="${dist}/${dist.zip.name}.zip">
247 <zipfileset dir="${basedir}" prefix="${dist.dir.name}" excludes="${zip.excludes}" />
248 </zip>
249</target>
250
251<target name="get-zipformat">
252<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
253 <input addproperty="zip.format" defaultvalue="zip">What type of compressed output file do you want to generate?
254Type one of: zip, tar.gz, tar.bz2
255Press enter for default: zip /></input>
256 <condition property="zip.type" value="targzip">
257 <equals arg1="tar.gz" arg2="${zip.format}"/>
258 </condition>
259 <condition property="zip.type" value="zip">
260 <equals arg1="zip" arg2="${zip.format}"/>
261 </condition>
262 <condition property="zip.type" value="tarbzip">
263 <equals arg1="tar.bz2" arg2="${zip.format}"/>
264 </condition>
265 <echo>You chose output file type: ${zip.type}</echo>
266 </target>
267</project>
Note: See TracBrowser for help on using the repository browser.