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