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

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

Better processing of chosen zip file type in target generate-download

File size: 10.0 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="bin" value="${basedir}/bin" />
22 <property name="QBRdata.rel.path" value="org/greenstone/gs3client/data" />
23 <property name="dlservices.rel.path" value="org/greenstone/gs3client/dlservices" />
24 <property name="gui.rel.path" value="org/greenstone/gs3client" />
25 <property name="gs3services.rel.path" value="org/greenstone/gs3services" />
26 <property name="exec.jar.name" value="GS3democlient.jar" /> <!-- name of the executable-->
27 <property name="download.zip.name" value="gs3_webservices_democlient" />
28 <property name="zip.excludes" value="bin/**,gs3democlient.properties" />
29
30 <!-- ============ project classpath: everything in the lib folder =================== -->
31 <path id="project.classpath">
32 <fileset dir="lib">
33 <include name="**/*.jar"/>
34 </fileset>
35 </path>
36
37<target name="usage" description="Prints out ant commands for the GS3 demo-client">
38 <echo>Type:</echo>
39 <echo>- ant build-demo-client</echo>
40 <echo> for (compiling) and creating the demo-client executable</echo>
41 <echo>- ant compile-demo-client</echo>
42 <echo> for compiling the democlient</echo>
43 <echo>- fedoraGS3jar</echo>
44 <echo> for generating the fedoraGS3.jar dependency file</echo>
45 <echo>- QBRdatajar</echo>
46 <echo> for generating the QBRdata.jar dependency file</echo>
47 <echo>- generate-download</echo>
48 <echo> for generating the zip/gzip/bzip file of the project</echo>
49 <echo>- ant clean-democlient</echo>
50 <echo> for deleting the *.class files from the GS3democlient's source</echo>
51 <echo>- ant clean</echo>
52 <echo> for deleting the *.class files from the GS3democlient and GS3Fedora sources</echo>
53 <echo>- ant dist-clean</echo>
54 <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>
55</target>
56
57
58<!-- Main targets: to build the GS3 web services demo-client and to create the tar.gz file for downloading -->
59<target name="build-demo-client" description="Creates the jar distribution file" depends="compile-demo-client">
60 <delete file="${exec.jar.name}" /> <!--For now: Let's delete it first and do a fresh rebuild-->
61 <jar destfile="${exec.jar.name}"
62 basedir="${democlient.rootdir}/"
63 manifest="Manifest.MF"
64 excludes="${QBRdata.rel.path}/*.class"
65 />
66<!-- LATER: only for tarring include source files, so that we can exclude the java files in this build?-->
67</target>
68
69<target name="generate-download" description="Generates the zip file of the lib and src folders and the executable ${exec.jar.name} file" depends="get-ziptype,ensure-exec-jar" if="zip.type">
70 <mkdir dir="${bin}" />
71 <antcall target="create-${zip.type}"/>
72</target>
73
74<!-- Compilation first ensures the existence of QBRdata.jar AND fedoraGS3.jar by checking whether these jars exist and if not, generating them. Then 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 that are outdated or when they have not been generated yet.-->
75<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar">
76 <javac srcdir="${democlient.rootdir}">
77 <classpath refid="project.classpath"/>
78 <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-->
79 </javac>
80</target>
81
82<!-- Cleaning targets -->
83<target name="clean-democlient" description="Removes all class files from the GS3demo-client">
84 <delete>
85 <fileset dir="${democlient.src}" includes="**/*.class"/>
86 </delete>
87</target>
88
89<target name="clean" description="Removes all class files from the GS3DemoClient and GS3Fedora source folders" depends="clean-democlient">
90 <delete>
91 <fileset dir="${fedorags3.src}" includes="**/*.class"/>
92 </delete>
93</target>
94
95<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">
96 <delete>
97 <fileset file="${basedir}/lib/fedoraGS3.jar"/>
98 <fileset file="${basedir}/lib/QBRdata.jar"/>
99 <fileset file="${basedir}/${exec.jar.name}"/>
100 <fileset file="${basedir}/gs3democlient.properties"/>
101 <fileset file="${bin}/${download.zip.name}.tar"/>
102 <fileset file="${bin}/${download.zip.name}.tar.gz"/>
103 <fileset file="${bin}/${download.zip.name}.zip"/>
104 <fileset file="${bin}/${download.zip.name}.tar.bz2"/>
105 </delete>
106</target>
107
108<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
109<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
110 <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}">
111 <classpath refid="project.classpath"/>
112 </javac>
113 <delete file="lib/QBRdata.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
114 <jar destfile="lib/QBRdata.jar"
115 basedir="${democlient.rootdir}/"
116 excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
117 </jar>
118</target>
119
120<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
121 <javac srcdir="${fedorags3.rootdir}">
122 <classpath refid="project.classpath"/>
123 </javac>
124 <delete file="lib/fedoraGS3.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
125 <jar destfile="lib/fedoraGS3.jar"
126 basedir="${fedorags3.rootdir}/"/>
127</target>
128
129<target name="update-gs3forclient.jar" description="Will update the class files in ${basedir}/lib/gs3_for_client.jar using svn to the latest versions of those files in Greenstone3's svn repository">
130</target>
131
132<!-- Targets that check for and ensure the existence of project-specific jar files -->
133<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
134 <condition property="QBRdata.exists">
135 <available file="${basedir}/lib/QBRdata.jar"/>
136 </condition>
137</target>
138
139<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
140 <antcall target="QBRdatajar"/>
141</target>
142
143<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
144 <condition property="fedoraGS3.exists">
145 <available file="${basedir}/lib/fedoraGS3.jar"/>
146 </condition>
147</target>
148
149<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
150 <antcall target="fedoraGS3jar"/>
151</target>
152
153<!-- generates the project's executable -->
154<target name="check-exec-jar" description="Checks for existence of executable file ${exec.jar.name}">
155 <condition property="executable.exists">
156 <available file="${basedir}/${exec.jar.name}"/>
157 </condition>
158</target>
159
160<target name="ensure-exec-jar" description="Will generate ${exec.jar.name} if it did not exist" depends="check-exec-jar" unless="executable.exists">
161 <antcall target="build-demo-client"/>
162</target>
163
164<!-- User input for generating compressed output file for one of the chosen file types (zip, gzip, or bzip)-->
165<target name="create-gzip" if="gzip" description="User chose to create a tar.gz file of the project">
166 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}" />
167 <gzip destfile="${bin}/${download.zip.name}.tar.gz" src="${bin}/${download.zip.name}.tar" />
168 <delete file="${bin}/${download.zip.name}.tar"/>
169</target>
170
171<target name="create-bzip" if="bzip" description="User chose to create a tar.bz2 file of the project">
172 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}"/>
173 <bzip2 destfile="${bin}/${download.zip.name}.tar.bz2" src="${bin}/${download.zip.name}.tar"/>
174 <delete file="${bin}/${download.zip.name}.tar"/>
175</target>
176
177<target name="create-zip" if="zip" description="User chose to create a zip file of the project">
178 <zip destfile="${bin}/${download.zip.name}.zip" basedir="${basedir}" excludes="${zip.excludes}"/>
179</target>
180
181<target name="get-ziptype">
182<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
183 <input addproperty="zip.type" defaultvalue="zip">What type of compressed output file do you want to generate.
184Choose from zip, gzip (for tar.gz), bzip (tar.bz2)?
185Press enter for default: zip /></input>
186 <echo>You chose output file type: ${zip.type}</echo>
187 <condition property="gzip">
188 <equals arg1="gzip" arg2="${zip.type}"/>
189 </condition>
190 <condition property="zip">
191 <equals arg1="zip" arg2="${zip.type}"/>
192 </condition>
193 <condition property="bzip">
194 <equals arg1="bzip" arg2="${zip.type}"/>
195 </condition>
196 </target>
197</project>
Note: See TracBrowser for help on using the repository browser.