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

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

Changes to usage target

File size: 10.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="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</echo>
50 <echo> for deleting the *.class files from the GS3democlient's source</echo>
51 <echo>- ant clean-all</echo>
52 <echo> for deleting the *.class files from the GS3democlient and GS3Fedora sources</echo>
53 <echo>- ant retain-sources-only</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">
70 <mkdir dir="${bin}" />
71 <antcall target="create-gzip"/>
72 <antcall target="create-zip"/>
73 <antcall target="create-bzip"/>
74</target>
75
76<!-- 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.-->
77<target name="compile-demo-client" description="Compiles the GS3 demo-client" depends="ensure-QBRdata-jar,ensure-fedoraGS3-jar">
78 <javac srcdir="${democlient.rootdir}">
79 <classpath refid="project.classpath"/>
80 <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-->
81 </javac>
82</target>
83
84<!-- Cleaning targets -->
85<target name="clean" description="Removes all class files from the GS3demo-client">
86 <delete>
87 <fileset dir="${democlient.src}" includes="**/*.class"/>
88 </delete>
89</target>
90
91<target name="clean-all" description="Removes all class files from the GS3DemoClient and GS3Fedora source folders" depends="clean">
92 <delete>
93 <fileset dir="${fedorags3.src}" includes="**/*.class"/>
94 </delete>
95</target>
96
97<target name="retain-sources-only" 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-all">
98 <delete>
99 <fileset file="${basedir}/lib/fedoraGS3.jar"/>
100 <fileset file="${basedir}/lib/QBRdata.jar"/>
101 <fileset file="${basedir}/${exec.jar.name}"/>
102 <fileset file="${basedir}/gs3democlient.properties"/>
103 <fileset file="${bin}/${download.zip.name}.tar"/>
104 <fileset file="${bin}/${download.zip.name}.tar.gz"/>
105 <fileset file="${bin}/${download.zip.name}.zip"/>
106 <fileset file="${bin}/${download.zip.name}.tar.bz2"/>
107 </delete>
108</target>
109
110<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
111<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
112 <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}">
113 <classpath refid="project.classpath"/>
114 </javac>
115 <delete file="lib/QBRdata.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
116 <jar destfile="lib/QBRdata.jar"
117 basedir="${democlient.rootdir}/"
118 excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
119 </jar>
120</target>
121
122<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
123 <javac srcdir="${fedorags3.rootdir}">
124 <classpath refid="project.classpath"/>
125 </javac>
126 <delete file="lib/fedoraGS3.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
127 <jar destfile="lib/fedoraGS3.jar"
128 basedir="${fedorags3.rootdir}/"/>
129</target>
130
131<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">
132</target>
133
134<!-- Targets that check for and ensure the existence of project-specific jar files -->
135<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
136 <condition property="QBRdata.exists">
137 <available file="${basedir}/lib/QBRdata.jar"/>
138 </condition>
139</target>
140
141<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
142 <antcall target="QBRdatajar"/>
143</target>
144
145<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
146 <condition property="fedoraGS3.exists">
147 <available file="${basedir}/lib/fedoraGS3.jar"/>
148 </condition>
149</target>
150
151<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
152 <antcall target="fedoraGS3jar"/>
153</target>
154
155<!-- generates the project's executable -->
156<target name="check-exec-jar" description="Checks for existence of executable file ${exec.jar.name}">
157 <condition property="executable.exists">
158 <available file="${basedir}/${exec.jar.name}"/>
159 </condition>
160</target>
161
162<target name="ensure-exec-jar" description="Will generate ${exec.jar.name} if it did not exist" depends="check-exec-jar" unless="executable.exists">
163 <antcall target="build-demo-client"/>
164</target>
165
166<!-- User input for generating compressed output file for one of the chosen file types (zip, gzip, or bzip)-->
167<target name="create-gzip" if="gzip" description="User chose to create a tar.gz file of the project">
168 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}"/>
169 <gzip destfile="${bin}/${download.zip.name}.tar.gz" src="${bin}/${download.zip.name}.tar" />
170 <delete file="${bin}/${download.zip.name}.tar"/>
171</target>
172
173<target name="create-bzip" if="bzip" description="User chose to create a tar.bz2 file of the project">
174 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}"/>
175 <bzip2 destfile="${bin}/${download.zip.name}.tar.bz2" src="${bin}/${download.zip.name}.tar"/>
176 <delete file="${bin}/${download.zip.name}.tar"/>
177</target>
178
179<target name="create-zip" if="zip" description="User chose to create a zip file of the project">
180 <zip destfile="${bin}/${download.zip.name}.zip" basedir="${basedir}" excludes="${zip.excludes}"/>
181</target>
182
183<target name="get-ziptype">
184<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
185 <input addproperty="zip.type" defaultvalue="zip">What type of compressed output file do you want to generate.
186Choose from zip, gzip (for tar.gz), bzip (tar.bz2)?
187Press enter for default: zip /></input>
188 <echo>You chose output file type: ${zip.type}</echo>
189 <condition property="gzip">
190 <equals arg1="gzip" arg2="${zip.type}"/>
191 </condition>
192 <condition property="zip">
193 <equals arg1="zip" arg2="${zip.type}"/>
194 </condition>
195 <condition property="bzip">
196 <equals arg1="bzip" arg2="${zip.type}"/>
197 </condition>
198 </target>
199
200</project>
Note: See TracBrowser for help on using the repository browser.