added unset_zone_id context for clients
[voldemort/jeffpc.git] / build.xml
blob5906a25915445dae41688b5cab2017785eac20bd
1 <?xml version="1.0"?>
3 <project name="voldemort" basedir="." default="all">
4   <property file="build.properties" />
6   <property name="name" value="voldemort" />
7   <property name="display.name" value="Voldemort" />
8   <property name="author" value="Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu" />
9   <property environment="env" />
11   <path id="main-classpath">
12     <fileset dir="${lib.dir}">
13       <include name="*.jar" />
14     </fileset>
15     <pathelement path="${classes.dir}" />
16   </path>
18   <!-- set the build number based on environment variable, otherwise blank -->
19   <property environment="env" description="System environment variables (including those set by Hudson)"/>
20   <condition property="curr.release.snapshot" value="${curr.release}-snapshot-${env.BUILD_NUMBER}" else="${curr.release}">
21        <and>
22           <isset property="env.BUILD_NUMBER" />
23           <not>
24               <equals arg1="" arg2="${env.BUILD_NUMBER}" trim="yes"/>
25           </not>
26        </and>
27   </condition>
29   <path id="contrib-classpath">
30     <pathelement path="${resources.dir}" />
31     <fileset dir="${dist.dir}">
32       <include name="${name}-${curr.release}.jar" />
33     </fileset>
34     <fileset dir="${contrib.root.dir}">
35       <include name="**/*.jar" />
36     </fileset>
37     <path refid="test-classpath" />
38   </path>
40   <path id="test-classpath">
41     <pathelement path="${resources.dir}" />
42     <pathelement path="${env.VOLD_TEST_JARS}" />
43     <path refid="main-classpath" />
44     <pathelement path="${testclasses.dir}" />
45   </path>
47   <path id="contrib-test-classpath">
48     <path refid="main-classpath" />
49     <path refid="contrib-classpath" />
50     <fileset dir="${dist.dir}">
51       <include name="${name}-contrib-${curr.release}.jar" />
52     </fileset>
53     <pathelement path="${testclasses.dir}" />
54   </path>
56   <macrodef name="replace-dir">
57     <attribute name="dir" />
58     <sequential>
59       <delete dir="@{dir}" />
60       <mkdir dir="@{dir}" />
61     </sequential>
62   </macrodef>
64   <target name="all" depends="clean, jar, test, contrib-jar, srcjar" description="Build all artifacts." />
66   <target name="clean" description="Delete generated files.">
67     <delete dir="${dist.dir}" />
68     <replace-dir dir="${javadoc.dir}" />
69   </target>
71   <target name="build" description="Compile main source tree java files">
72     <replace-dir dir="${classes.dir}" />
73     <!-- copy non-java files to classes dir to load from classpath -->
74     <copy todir="${classes.dir}">
75       <fileset dir="${java.dir}">
76         <exclude name="**/*.java" />
77         <exclude name="**/*.html" />
78         <exclude name="**/log4j.properties" />
79       </fileset>
80     </copy>
81     <replace-dir dir="META-INF" />
82         <echo message="creating manifest"/>
83     <manifest file="META-INF/MANIFEST.MF">   
84       <attribute name="Voldemort-Implementation-Version" value="${curr.release}" />
85       <attribute name="Implementation-Title" value="Voldemort" />
86       <attribute name="Implementation-Version" value="${curr.release}" />
87       <attribute name="Implementation-Vendor" value="LinkedIn" />
88     </manifest>
89     <!-- place to put log4j.properties -->
90     <replace-dir dir="${resources.dir}"/>
91     <copy file="${java.dir}/log4j.properties" todir="${resources.dir}"/>
92     <javac destdir="${classes.dir}" target="${javac.version}" source="${javac.version}" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
93       <src path="${java.dir}" />
94       <classpath refid="main-classpath" />
95     </javac>
96   </target>
98   <target name="buildtest" description="Compile test classes">
99     <replace-dir dir="${testclasses.dir}" />
100     <copy todir="${testclasses.dir}">
101       <fileset dir="${commontestsrc.dir}">
102         <exclude name="**/*.java" />
103         <exclude name="**/*.html" />
104       </fileset>
105     </copy>
106     <copy todir="${testclasses.dir}">
107       <fileset dir="${unittestsrc.dir}">
108         <exclude name="**/*.java" />
109         <exclude name="**/*.html" />
110       </fileset>
111     </copy>
112     <javac destdir="${testclasses.dir}" target="${javac.version}" source="${javac.version}" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
113       <src path="${unittestsrc.dir}" />
114       <src path="${inttestsrc.dir}" />
115       <src path="${commontestsrc.dir}" />
116       <src path="${longtestsrc.dir}" />
117       <classpath refid="main-classpath" />
118     </javac>
119   </target>
121   <target name="test" depends="build, buildtest" description="Build test jar file">
122     <jar destfile="${dist.dir}/${name}-test-${curr.release}.jar">
123       <fileset dir="${testclasses.dir}" />
124     </jar>
125   </target>
127   <!--
128     Use protoc version 2.3.0 to recompile by hand:
129       https://code.google.com/p/protobuf/downloads/detail?name=protobuf-2.3.0.tar.gz&can=2&q=
131     Below, '<DASH/>' means '-'. This was done to nest double-dashes within xml comment.
133   <target name="protobuff" description="Generate source files from .proto files">
134     <pathconvert property="proto.sources" pathsep=" ">
135       <path id="proto-files">
136         <fileset dir="${protobuff.dir}" />
137       </path>
138     </pathconvert>
140     <property name="proto.path" location="${protobuff.dir}"/>
141     <property name="javaout.path" location="${java.dir}"/>
142     <property name="pythonout.path" location="${python.proto.dir}"/>
143     <exec executable="protoc" failonerror="true">
144       <arg value="<DASH/><DASH/>proto_path=${proto.path}"/>
145       <arg value=""<DASH/><DASH/>java_out=${javaout.path}"/>
146       <arg value=""<DASH/><DASH/>python_out=${pythonout.path}"/>
147       <arg line="${proto.sources}"/>
148     </exec>
149   </target>
150   -->
152   <target name="jar" depends="build" description="Build server jar file">
153     <jar destfile="${dist.dir}/${name}-${curr.release}.jar"  manifest="META-INF/MANIFEST.MF">
154       <fileset dir="${classes.dir}">
155         <include name="**/*.*" />
156       </fileset>
157       <!-- include xsds -->
158       <fileset dir="${java.dir}">
159         <include name="**/*.xsd" />
160       </fileset>
161         
162         <fileset dir=".">
163                         <include name="META-INF/MANIFEST.MF" />
164       </fileset>
165     </jar>
166   </target>
168   <target name="srcjar" description="Build source jar file">
169     <mkdir dir="${dist.dir}" />
170     <jar destfile="${dist.dir}/${name}-${curr.release}-src.jar">
171       <fileset dir="${java.dir}">
172         <include name="**/*.java" />
173       </fileset>
174     </jar>
175   </target>
177   <target name="alljar" depends="build, contrib-build" description="Build a jar file that includes all contrib code.">
178     <jar destfile="${dist.dir}/${name}-${curr.release}-all.jar">
179       <fileset dir="${classes.dir}">
180         <include name="**/*.*" />
181       </fileset>
182       <fileset dir="${contrib.classes.dir}">
183         <include name="**/*.*" />
184       </fileset>
185       <!-- include xsds -->
186       <fileset dir="${java.dir}">
187         <include name="**/*.xsd" />
188       </fileset>
189     </jar>
190   </target>
192   <target name="war" depends="build" description="Build server war file">
193     <war destfile="${dist.dir}/${name}.war" webxml="web.xml" basedir="${classes.dir}">
194       <classes dir="${classes.dir}"/>
195       <lib dir="${lib.dir}">
196         <exclude name="${lib.dir}/servlet-api*.jar"/>
197         <exclude name="${lib.dir}/src/**"/>
198       </lib>
199     </war>
200   </target>
202   <target name="contrib-build" depends="build, buildtest" description="Compile contrib packages (java and test) ">
203     <replace-dir dir="${contrib.classes.dir}" />
204     <javac destdir="${contrib.classes.dir}" target="${javac.version}" source="${javac.version}" debug="true" deprecation="false" failonerror="true" includeantruntime="false">
205       <src path="${contrib.root.dir}" />
206       <src path="${contrib.root.dir}" />
207       <classpath refid="main-classpath" />
208       <classpath refid="contrib-classpath" />
209     </javac>
210     <copy todir="${contrib.classes.dir}">
211       <fileset dir="${contrib.root.dir}/ec2-testing/resources" />
212     </copy>
213   </target>
215   <target name="contrib-jar" depends="contrib-build" description="Build contrib jar file">
216     <jar destfile="${dist.dir}/${name}-contrib-${curr.release}.jar">
217       <fileset dir="${contrib.classes.dir}">
218         <include name="**/*.*" />
219       </fileset>
220     </jar>
221   </target>
223   <target name="contrib-srcjar" description="Build contrib source jar file">
224     <mkdir dir="${dist.dir}" />
225     <jar destfile="${dist.dir}/${name}-contrib-${curr.release}-src.jar">
226       <fileset dir="${contrib.root.dir}/**/java">
227         <include name="**/*.java" />
228       </fileset>
229     </jar>
230   </target>
232   <target name="contrib-junit" depends="contrib-jar" description="Run contrib junit tests except EC2 and Krati tests.">
233     <replace-dir dir="${contribtestreport.dir}" />
234     <replace-dir dir="${contribtesthtml.dir}" />
235     <junit printsummary="yes" maxmemory="2048m" showoutput="true" failureProperty="test.failure">
236       <classpath refid="contrib-test-classpath" />
237       <formatter type="xml" />
238       <batchtest fork="yes" todir="${contribtestreport.dir}">
239         <fileset dir="${contrib.classes.dir}">
240           <include name="**/*Test.class" />
241           <exclude name="**/*PerformanceTest.class" />
242           <exclude name="**/*RemoteTest.class" />
243           <exclude name="**/Ec2*Test.class" />
244           <exclude name="**/Krati*Test.class" />
245           <exclude name="**/HadoopStoreBuilder*Test.class" />
246         </fileset>
247       </batchtest>
248     </junit>
249     <junitreport todir="${contribtesthtml.dir}">
250       <fileset dir="${contribtestreport.dir}">
251         <include name="TEST-*.xml" />
252       </fileset>
253       <report todir="${contribtesthtml.dir}" format="frames" />
254     </junitreport>
255   </target>
257   <target name="ec2testing-junit" depends="all" description="Run EC2 testing contrib junit tests.">
258     <copy todir="${testclasses.dir}">
259       <fileset dir="${contrib.root.dir}/ec2-testing/resources" />
260     </copy>
261     <replace-dir dir="${contribtestreport.dir}" />
262     <replace-dir dir="${contribtesthtml.dir}" />
263     <junit printsummary="yes" maxmemory="2048m" showoutput="true" failureProperty="test.failure">
264       <syspropertyset>
265         <propertyref prefix="ec2" />
266       </syspropertyset>
267       <classpath refid="contrib-test-classpath" />
268       <formatter type="xml" />
269       <batchtest fork="yes" todir="${contribtestreport.dir}">
270         <fileset dir="${contrib.classes.dir}">
271           <include name="**/Ec2SmokeTest.class" />
272         </fileset>
273       </batchtest>
274     </junit>
275     <junitreport todir="${contribtesthtml.dir}">
276       <fileset dir="${contribtestreport.dir}">
277         <include name="TEST-*.xml" />
278       </fileset>
279       <report todir="${contribtesthtml.dir}" format="frames" />
280     </junitreport>
281   </target>
283   <target name="ec2testing-gossip" depends="contrib-jar" description="Run gossip tests on EC2.">
284     <copy todir="${testclasses.dir}">
285       <fileset dir="${contrib.root.dir}/ec2-testing/resources" />
286     </copy>
287     <replace-dir dir="${contribtestreport.dir}" />
288     <replace-dir dir="${contribtesthtml.dir}" />
289     <junit printsummary="yes" maxmemory="2048m" showoutput="true" failureProperty="test.failure">
290       <syspropertyset>
291         <propertyref prefix="ec2" />
292         <propertyref  prefix="log4j" />
293         <propertyref  prefix="gossip" />
294       </syspropertyset>
295       <classpath refid="contrib-test-classpath" />
296       <formatter type="xml" />
297       <batchtest fork="yes" todir="${contribtestreport.dir}">
298         <fileset dir="${contrib.classes.dir}">
299           <include name="**/Ec2GossipTest.class" />
300         </fileset>
301       </batchtest>
302     </junit>
303     <junitreport todir="${contribtesthtml.dir}">
304       <fileset dir="${contribtestreport.dir}">
305         <include name="TEST-*.xml" />
306       </fileset>
307       <report todir="${contribtesthtml.dir}" format="frames" />
308     </junitreport>
309   </target>
311   <target name="ec2testing-rebalancing" depends="contrib-jar" description="Run rebalancing tests on EC2.">
312     <copy todir="${testclasses.dir}">
313       <fileset dir="${contrib.root.dir}/ec2-testing/resources" />
314     </copy>
315     <replace-dir dir="${contribtestreport.dir}" />
316     <replace-dir dir="${contribtesthtml.dir}" />
317     <junit printsummary="yes" maxmemory="2048m" showoutput="true" failureProperty="test.failure">
318       <syspropertyset>
319         <propertyref prefix="ec2" />
320         <propertyref  prefix="log4j" />
321         <propertyref  prefix="rebalancing" />
322       </syspropertyset>
323       <classpath refid="contrib-test-classpath" />
324       <formatter type="xml" />
325       <batchtest fork="yes" todir="${contribtestreport.dir}">
326         <fileset dir="${contrib.classes.dir}">
327           <include name="**/Ec2RebalancingTest.class" />
328         </fileset>
329       </batchtest>
330     </junit>
331     <junitreport todir="${contribtesthtml.dir}">
332       <fileset dir="${contribtestreport.dir}">
333         <include name="TEST-*.xml" />
334       </fileset>
335       <report todir="${contribtesthtml.dir}" format="frames" />
336     </junitreport>
337   </target>
339   <macrodef name="create-release-artifacts">
340     <attribute name="version" />
341     <sequential>
342     <antcall target="all"/>
343     <zip destfile="${dist.dir}/${name}-@{version}.zip">
344       <zipfileset dir="." prefix="voldemort-@{version}" filemode="755" includes="bin/*"/>
345       <zipfileset dir="." prefix="voldemort-@{version}" includes="**">
346         <exclude name="${dist.dir}/*classes/"/>
347         <exclude name="bin/*"/>
348         <exclude name=".git*/**"/>
349       </zipfileset>
350     </zip>
351     <tar destfile="${dist.dir}/${name}-@{version}.tar.gz" compression="gzip" longfile="gnu">
352       <tarfileset dir="." prefix="voldemort-@{version}" filemode="755" includes="bin/*"/>
353       <tarfileset dir="." prefix="voldemort-@{version}" includes="**">
354         <exclude name="${dist.dir}/*classes/"/>
355         <exclude name="${dist.dir}/*.zip"/>
356         <exclude name="bin/*"/>
357         <exclude name=".git*/**"/>
358       </tarfileset>
359     </tar>
360     </sequential>
361   </macrodef>
363   <target name="snapshot"  description="Create a release-snapshot zip file with everything pre-built.">
364     <create-release-artifacts version="${curr.release.snapshot}" />
365   </target>
367   <target name="release" description="Create a release zip file with everything pre-built.">
368     <create-release-artifacts version="${curr.release}" />
369   </target>
371   <target name="hadoop-benchmark-jar" depends="build, contrib-build"
372     description="Build a jar file that includes all contrib code plus the necessary jars for running the hadoop benchmark.">
373     <jar destfile="${dist.dir}/hadoop-benchmark.jar">
374       <fileset dir="${classes.dir}">
375         <include name="**/*.*" />
376       </fileset>
377       <fileset dir="${contrib.classes.dir}">
378         <include name="**/*.*" />
379       </fileset>
380       <!-- include xsds -->
381       <fileset dir="${java.dir}">
382         <include name="**/*.xsd" />
383       </fileset>
384       <fileset dir="">
385         <include name="lib/jdom*.jar"/>
386         <include name="lib/google-collect*.jar"/>
387         <include name="lib/commons-lang*.jar"/>
388       </fileset>
389     </jar>
390   </target>
392   <target name="junit" depends="build, buildtest" description="Run junit tests.">
393     <replace-dir dir="${testreport.dir}" />
394     <replace-dir dir="${testhtml.dir}" />
395     <junit printsummary="yes" showoutput="true" maxmemory="2048m" timeout="1200000">
396       <classpath refid="test-classpath" />
397       <formatter type="xml" />
398       <batchtest fork="yes" todir="${testreport.dir}">
399         <fileset dir="${unittestsrc.dir}">
400           <include name="**/*Test.java" />
401           <exclude name="**/Abstract*.java" />
402         </fileset>
403       </batchtest>
404     </junit>
405     <junitreport todir="${testhtml.dir}">
406       <fileset dir="${testreport.dir}">
407         <include name="TEST-*.xml" />
408       </fileset>
409       <report todir="${testhtml.dir}" format="frames" />
410     </junitreport>
411   </target>
413   <target name="junit-long" depends="build, buildtest, junit" description="Run long junit tests that uses larger data sets than normal junit tests.">
414     <replace-dir dir="${longtestreport.dir}" />
415     <replace-dir dir="${longtesthtml.dir}" />
416     <junit printsummary="yes" showoutput="true" maxmemory="2048m" fork="yes" timeout="5400000">
417       <classpath refid="test-classpath" />
418       <formatter type="xml" />
419       <batchtest todir="${longtestreport.dir}">
420         <fileset dir="${longtestsrc.dir}">
421           <include name="**/*Test.java" />
422         </fileset>
423       </batchtest>
424     </junit>
425     <junitreport todir="${longtesthtml.dir}">
426       <fileset dir="${longtestreport.dir}">
427         <include name="TEST-*.xml" />
428       </fileset>
429       <report todir="${longtesthtml.dir}" format="frames" />
430     </junitreport>
431   </target>
433   <target name="junit-rebalance" depends="build, buildtest" description="Run junit tests only for rebalance.">
434     <replace-dir dir="${testreport.dir}" />
435     <replace-dir dir="${testhtml.dir}" />
436     <junit printsummary="yes" showoutput="true" maxmemory="2048m" timeout="1200000">
437       <classpath refid="test-classpath" />
438       <formatter type="xml" />
439       <batchtest fork="yes" todir="${testreport.dir}">
440         <fileset dir="${unittestsrc.dir}">
441           <include name="**/*Rebalance*Test.java" />
442           <exclude name="**/Abstract*.java" />
443         </fileset>
444       </batchtest>
445     </junit>
446     <junitreport todir="${testhtml.dir}">
447       <fileset dir="${testreport.dir}">
448         <include name="TEST-*.xml" />
449       </fileset>
450       <report todir="${testhtml.dir}" format="frames" />
451     </junitreport>
452   </target>
454   <target name="junit-long-rebalance" depends="build, buildtest, junit-rebalance" description="Run long junit rebalance tests that uses larger data sets than normal junit tests.">
455     <replace-dir dir="${longtestreport.dir}" />
456     <replace-dir dir="${longtesthtml.dir}" />
457     <junit printsummary="yes" showoutput="true" maxmemory="2048m" fork="yes" timeout="5400000">
458       <classpath refid="test-classpath" />
459       <formatter type="xml" />
460       <batchtest todir="${longtestreport.dir}">
461         <fileset dir="${longtestsrc.dir}">
462           <include name="**/*Rebalance*Test.java" />
463         </fileset>
464       </batchtest>
465     </junit>
466     <junitreport todir="${longtesthtml.dir}">
467       <fileset dir="${longtestreport.dir}">
468         <include name="TEST-*.xml" />
469       </fileset>
470       <report todir="${longtesthtml.dir}" format="frames" />
471     </junitreport>
472   </target>
474   <target name="junit-test" depends="build, buildtest, contrib-jar" description="Run single junit test for class ClassName with -Dtest.name=[ClassName]  (Note: Use the class name, not the file name with the .java extension)">
475     <replace-dir dir="${singletestreport.dir}" />
476     <replace-dir dir="${singletesthtml.dir}" />
477     <junit printsummary="on" showoutput="true" maxmemory="4096m">
478       <classpath refid="contrib-test-classpath" />
479       <classpath path="${log4j.properties.dir}" />
480       <formatter type="plain" />
481       <formatter type="xml" />
482       <test name="${test.name}"  todir="${singletestreport.dir}"/>
483     </junit>
484     <junitreport todir="${singletesthtml.dir}">
485       <fileset dir="${singletestreport.dir}">
486         <include name="TEST-*.xml" />
487       </fileset>
488       <report todir="${singletesthtml.dir}" format="frames" />
489     </junitreport>
490   </target>
492   <target name="junit-all" depends="junit-long, contrib-junit" description="Run All junit tests including contrib.">
493   </target>
495   <macrodef name="make-javadocs">
496     <attribute name="dir" />
497     <attribute name="packagenames" />
498     <attribute name="javadir" />
499     <sequential>
500       <replace-dir dir="@{dir}" />
501       <javadoc sourcepath="@{javadir}" destdir="@{dir}" windowtitle="${display.name}" source="${javac.version}" author="true" version="true" use="true" packagenames="@{packagenames}">
502         <doctitle>${display.name}</doctitle>
503         <bottom>${author}</bottom>
504         <classpath refid="main-classpath" />
505       </javadoc>
506     </sequential>
507   </macrodef>
509   <target name="docs" description="Create complete Javadoc documentation">
510     <make-javadocs dir="${javadoc.dir}/all" packagenames="*" javadir="${java.dir}"/>
511     <make-javadocs dir="${javadoc.dir}/client" packagenames="voldemort.versioning.*, voldemort.client.*,voldemort.serialization.*" javadir="${java.dir}"/>
512   </target>
514   <target name="redeploy" depends="war, deploy">
515   </target>
517   <taskdef file="tomcat-tasks.properties">
518     <classpath>
519       <path location="${lib.dir}/catalina-ant.jar" />
520     </classpath>
521   </taskdef>
523   <target name="list" description="List Tomcat applications">
524     <list url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" />
525   </target>
527   <target name="deploy" description="Deploy application" depends="war">
528     <deploy url="${tomcat.manager.url}" username="${tomcat.manager.username}" password="${tomcat.manager.password}" path="${tomcat.context}" update="true" war="file:${dist.dir}/${name}.war" />
529   </target>
531   <target name="undeploy" description="Undeploy application">
532     <undeploy url="${tomcat.manager.url}"
533                  username="${tomcat.manager.username}"
534                  password="${tomcat.manager.password}"
535                  path="${tomcat.context}"/>
536   </target>
538 </project>