forked from twitter/elephant-bird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
221 lines (191 loc) · 8.16 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<project name="elephant-bird" default="release-jar" basedir=".">
<!-- Global properties for this build -->
<property name="jar.name" value="elephant-bird" />
<property name="version" value="1.0" />
<!-- Directories -->
<property name="build.dir" location="build" />
<property name="javadoc.dir" location="javadoc" />
<property name="dist.dir" location="dist" />
<property name="src.dir" location="src" />
<property name="src.java.dir" location="${src.dir}/java" />
<property name="src.proto.dir" location="${src.dir}/proto" />
<property name="test.src.dir" location="${src.dir}/test" />
<property name="src.gen.java.dir" location="${build.dir}/gen-java" />
<property name="classes.dir" location="${build.dir}/classes" />
<property name="lib.dir" value="${basedir}/lib"/>
<property name="test.lib.dir" value="${lib.dir}"/>
<property name="test.build.dir" value="${build.dir}/test"/>
<property name="test.generated.dir" value="${test.build.dir}/src"/>
<property name="test.build.data" value="${test.build.dir}/data"/>
<property name="test.log.dir" value="${test.build.dir}/logs"/>
<property name="test.build.classes" value="${test.build.dir}/classes"/>
<property name="test.include" value="Test*"/>
<property name="test.classpath.id" value="test.classpath"/>
<property name="test.output" value="no"/>
<property name="test.timeout" value="900000"/>
<property name="test.junit.output.format" value="plain"/>
<property name="test.junit.printsummary" value="yes" />
<property name="test.junit.fork.mode" value="perTest" />
<property name="test.junit.haltonfailure" value="no" />
<property name="test.junit.maxmemory" value="512m" />
<path id="test.classpath">
<pathelement location="${classes.dir}"/>
<pathelement location="${test.build.classes}"/>
<pathelement location="${basedir}/bin}"/>
<fileset dir="${test.lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<target name="debug" description="sets properties for debugging (logging on, debug symbols, etc)">
<echo message="Building in debug mode..."/>
<property name="compile.mode" value="debug"/>
<property name="java.debug" value="true"/>
</target>
<target name="release" description="sets properties for release builds.">
<echo message="Building in release mode..."/>
<property name="compile.mode" value="release"/>
<property name="java.debug" value="false"/>
</target>
<target name="noproto" depends="init">
<echo message="building without protobuf support" />
<property name="noprotobuf" value="yes" />
<compile-noprotobuf />
</target>
<target name="init">
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${test.build.dir}" />
</target>
<macrodef name="compile-noprotobuf">
<sequential>
<!-- Compile the java code from ${src.java} into ${build} -->
<javac srcdir="${src.java.dir}" destdir="${classes.dir}" debug="${java.debug}" debuglevel="lines,vars,source" excludes="**/*Protobuf*, **/proto/">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</sequential>
</macrodef>
<macrodef name="compile-java-protobuf">
<sequential>
<!-- Compile the java code from ${src.java} into ${build} -->
<javac srcdir="${src.java.dir}" destdir="${classes.dir}" debug="${java.debug}" debuglevel="lines,vars,source" includes="**/*Protobuf*, **/proto/">
<classpath>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javac>
</sequential>
</macrodef>
<target name="compile" depends="init, compile-protobuf" description="compile the source">
<compile-noprotobuf />
</target>
<macrodef name="generate-protobuf">
<sequential>
<mkdir dir="${src.gen.java.dir}" />
<property name="protoc.bin" value="protoc" />
<apply executable="${protoc.bin}" failonerror="true" skipemptyfilesets="true" verbose="true">
<env key="PATH" path="${env.PATH}:." />
<arg value="--proto_path=${src.proto.dir}" />
<arg value="--java_out=${src.gen.java.dir}" />
<fileset dir="${src.proto.dir}" includes="**/*.proto" />
</apply>
</sequential>
</macrodef>
<macrodef name="compile-generated-protobuf">
<sequential>
<javac srcdir="${src.gen.java.dir}" destdir="${classes.dir}" deprecation="on">
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
<include name="**/*.java" />
</javac>
</sequential>
</macrodef>
<target name="compile-protobuf" depends="init" unless="noprotobuf">
<generate-protobuf />
<compile-generated-protobuf />
<compile-java-protobuf />
</target>
<target name="jar" depends="compile" description="generate the distribution">
<!-- Create the distribution directory -->
<mkdir dir="${dist.dir}"/>
<!-- Delete the old jar file -->
<delete file="${dist.dir}/${jar.name}-${version}.jar"/>
<jar jarfile="${dist.dir}/${jar.name}-${version}.jar">
<fileset dir="${classes.dir}"/>
</jar>
</target>
<target name="javadoc" depends="compile" description="generate documentation" >
<delete dir="${javadoc.dir}" />
<javadoc destdir="${javadoc.dir}">
<fileset dir="${src.java.dir}" />
<fileset dir="${src.gen.java.dir}" />
<classpath>
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</classpath>
</javadoc>
</target>
<target name="debug-jar" description="Build debug and jar" depends="debug,jar"/>
<target name="release-jar" description="Build release and jar" depends="release,jar"/>
<target name="clean" description="clean up">
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build.dir}"/>
<delete dir="${classes.dir}" />
<delete dir="${dist.dir}"/>
</target>
<target name="examples" depends="jar" description="Compile the examples">
<ant dir="examples" />
</target>
<target name="compile-java-tests" depends="compile, compile-protobuf, examples" >
<echo message="classes dir: ${classes.dir}" />
<delete dir="${test.build.classes}"/>
<mkdir dir="${test.build.classes}"/>
<javac srcdir="${test.src.dir}" destdir="${test.build.classes}" deprecation="on" debug="${java.debug}" debuglevel="lines,vars,source">
<classpath refid="${test.classpath.id}"/>
<include name="**/*.java" />
</javac>
</target>
<target name="test" depends="compile-java-tests"
description="Run unit tests">
<delete dir="${test.log.dir}"/>
<mkdir dir="${test.log.dir}"/>
<junit showoutput="${test.output}"
printsummary="${test.junit.printsummary}"
haltonfailure="${test.junit.haltonfailure}"
fork="yes"
forkmode="${test.junit.fork.mode}"
maxmemory="${test.junit.maxmemory}"
dir="${basedir}" timeout="${test.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="test.cache.data" value="${test.cache.data}"/>
<sysproperty key="test.debug.data" value="${test.debug.data}"/>
<sysproperty key="test.log.dir" value="${test.log.dir}"/>
<sysproperty key="test.source.dir" value="${test.src.dir}"/>
<sysproperty key="test.build.extraconf" value="${test.build.extraconf}" />
<sysproperty key="java.library.path"
value="${lib.dir}/*.jar:${classes.dir}:${test.build.classes}:${basedir}/bin"/>
<classpath refid="${test.classpath.id}"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.log.dir}" unless="testcase">
<fileset dir="${test.src.dir}"
includes="**/${test.include}.java"
excludes="**/${test.exclude}.java" />
</batchtest>
<batchtest todir="${test.log.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
</project>