source: other-projects/trunk/gs3-webservices-democlient/build-forAnt1-6-5.xml@ 15317

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

Build.xml file that will work with ant 1.6.5 but: 1.Can't update CheckJavaVersion or gs3_for_client.jar by copying files from Greenstone SVN; 2. Dist compressed zip files do not extract into a custom directory, all contents are extracted in dir.

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