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

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

Doesn't include log4j.properties or logs folder when generating the zips

File size: 10.4 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="log4j.propFile" value="log4j.properties" />
29 <property name="zip.excludes" value="bin/**,logs/**,gs3democlient.properties,${log4j.propFile}" />
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 <mkdir dir="${basedir}/logs" /> <!-- Need a logs dir for outputting log4j stuff-->
61 <delete file="${exec.jar.name}" /> <!--For now: Let's delete it first and do a fresh rebuild-->
62 <jar destfile="${exec.jar.name}"
63 basedir="${democlient.rootdir}/"
64 manifest="Manifest.MF"
65 excludes="${QBRdata.rel.path}/*.class"
66 />
67 <copy file="${src.dir}/${log4j.propFile}" tofile="${basedir}/${log4j.propFile}"/>
68<!-- LATER: only for tarring include source files, so that we can exclude the java files in this build?-->
69</target>
70
71<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">
72 <mkdir dir="${bin}" />
73 <antcall target="create-${zip.type}"/>
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-democlient" 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" description="Removes all class files from the GS3DemoClient and GS3Fedora source folders" depends="clean-democlient">
92 <delete>
93 <fileset dir="${fedorags3.src}" includes="**/*.class"/>
94 </delete>
95</target>
96
97<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">
98 <delete includeEmptyDirs="true" failonerror="false">
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 dir="logs"/>
104 <fileset file="${log4j.propFile}"/>
105 <fileset file="${bin}/${download.zip.name}.tar"/>
106 <fileset file="${bin}/${download.zip.name}.tar.gz"/>
107 <fileset file="${bin}/${download.zip.name}.zip"/>
108 <fileset file="${bin}/${download.zip.name}.tar.bz2"/>
109 </delete>
110</target>
111
112<!-- Targets to generate the project-specific jar files QBRdata.jar and fedoraGS3.jar -->
113<target name="QBRdatajar" description="Compiles and creates the QBRdata.jar file needed by GS3demo-client">
114 <javac srcdir="${democlient.rootdir}/${QBRdata.rel.path}">
115 <classpath refid="project.classpath"/>
116 </javac>
117 <delete file="lib/QBRdata.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
118 <jar destfile="lib/QBRdata.jar"
119 basedir="${democlient.rootdir}/"
120 excludes="${gui.rel.path}/*.*,${dlservices.rel.path}/**,${gs3services.rel.path}/**">
121 </jar>
122</target>
123
124<target name="fedoraGS3jar" description="Compiles and creates the fedoraGS3.jar file needed by GS3demo-client">
125 <javac srcdir="${fedorags3.rootdir}">
126 <classpath refid="project.classpath"/>
127 </javac>
128 <delete file="lib/fedoraGS3.jar" /> <!--For now: Let's delete it first and do a fresh rebuild-->
129 <jar destfile="lib/fedoraGS3.jar"
130 basedir="${fedorags3.rootdir}/"/>
131</target>
132
133<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">
134</target>
135
136<!-- Targets that check for and ensure the existence of project-specific jar files -->
137<target name="check-QBRdata-jar" description="Checks for existence of dependency file QBRdata.jar">
138 <condition property="QBRdata.exists">
139 <available file="${basedir}/lib/QBRdata.jar"/>
140 </condition>
141</target>
142
143<target name="ensure-QBRdata-jar" description="Will generate QBRdata.jar if it did not exist" depends="check-QBRdata-jar" unless="QBRdata.exists">
144 <antcall target="QBRdatajar"/>
145</target>
146
147<target name="check-fedoraGS3-jar" description="Checks for existence of dependency file fedoraGS3.jar">
148 <condition property="fedoraGS3.exists">
149 <available file="${basedir}/lib/fedoraGS3.jar"/>
150 </condition>
151</target>
152
153<target name="ensure-fedoraGS3-jar" description="Will generate fedoraGS3.jar if it did not exist" depends="check-fedoraGS3-jar" unless="fedoraGS3.exists">
154 <antcall target="fedoraGS3jar"/>
155</target>
156
157<!-- generates the project's executable -->
158<target name="check-exec-jar" description="Checks for existence of executable file ${exec.jar.name}">
159 <condition property="executable.exists">
160 <available file="${basedir}/${exec.jar.name}"/>
161 </condition>
162</target>
163
164<target name="ensure-exec-jar" description="Will generate ${exec.jar.name} if it did not exist" depends="check-exec-jar" unless="executable.exists">
165 <antcall target="build-demo-client"/>
166</target>
167
168<!-- User input for generating compressed output file for one of the chosen file types (zip, gzip, or bzip)-->
169<target name="create-gzip" if="gzip" description="User chose to create a tar.gz file of the project">
170 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}" />
171 <gzip destfile="${bin}/${download.zip.name}.tar.gz" src="${bin}/${download.zip.name}.tar" />
172 <delete file="${bin}/${download.zip.name}.tar"/>
173</target>
174
175<target name="create-bzip" if="bzip" description="User chose to create a tar.bz2 file of the project">
176 <tar destfile="${bin}/${download.zip.name}.tar" basedir="${basedir}" excludes="${zip.excludes}"/>
177 <bzip2 destfile="${bin}/${download.zip.name}.tar.bz2" src="${bin}/${download.zip.name}.tar"/>
178 <delete file="${bin}/${download.zip.name}.tar"/>
179</target>
180
181<target name="create-zip" if="zip" description="User chose to create a zip file of the project">
182 <zip destfile="${bin}/${download.zip.name}.zip" basedir="${basedir}" excludes="${zip.excludes}"/>
183</target>
184
185<target name="get-ziptype">
186<!--<input addproperty="zip.type" validargs="zip,gzip,bzip">--><!-- doesn't work with default value-->
187 <input addproperty="zip.type" defaultvalue="zip">What type of compressed output file do you want to generate.
188Choose from zip, gzip (for tar.gz), bzip (tar.bz2)?
189Press enter for default: zip /></input>
190 <echo>You chose output file type: ${zip.type}</echo>
191 <condition property="gzip">
192 <equals arg1="gzip" arg2="${zip.type}"/>
193 </condition>
194 <condition property="zip">
195 <equals arg1="zip" arg2="${zip.type}"/>
196 </condition>
197 <condition property="bzip">
198 <equals arg1="bzip" arg2="${zip.type}"/>
199 </condition>
200 </target>
201</project>
Note: See TracBrowser for help on using the repository browser.