forked from angushe/elephant-bird
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
267 lines (234 loc) · 10.3 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<project name="elephant-bird"
default="jar"
xmlns:ivy="antlib:org.apache.ivy.ant"
xmlns:artifact="artifact:org.apache.maven.artifact.ant">
<property file="${basedir}/libraries.properties"/>
<property name="build.dir" location="${basedir}/build"/>
<property name="javadoc.dir" location="javadoc" />
<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="src.thrift.dir" location="${src.dir}/thrift" />
<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="test.build.dir" value="${build.dir}/test"/>
<property name="test.thrift.gen.java.dir" value="${test.build.dir}/thrift/gen-java"/>
<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.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="perBatch" />
<property name="test.junit.haltonfailure" value="no" />
<property name="test.junit.maxmemory" value="512m" />
<!-- Set to enable LZO tests. For example:
$ ant -Dtest.library.path=/path/to/libgplcompression/lib/native/Mac_OS_X-x86_64-64 test
-->
<property name="test.library.path" value="none"/>
<property name="thrift.version.expected" value="Thrift version 0.5.0"/>
<property name="protobuf.version.expected" value="libprotoc 2.3.0"/>
<property name="compile.lib.dir" location="${build.dir}/lib/compile"/>
<property name="test.lib.dir" location="${build.dir}/lib/test"/>
<property name="jar.name" value="elephant-bird"/>
<property name="version" value="2.1.8"/>
<property name="jar.file" location="${build.dir}/${jar.name}-${version}.jar"/>
<property name="maven.repo" value="http://repo1.maven.org/maven2"/>
<property name="ivy.version" value="2.2.0"/>
<macrodef name="_check_compiler">
<attribute name="compiler"/>
<attribute name="versionArg"/>
<attribute name="versionExpected"/>
<sequential>
<exec executable="@{compiler}" outputproperty="@{compiler}.version.actual">
<arg value="@{versionArg}"/>
</exec>
<fail message="Expected @{compiler} @{versionExpected} but you have ${@{compiler}.version.actual}">
<condition>
<not>
<contains string="${@{compiler}.version.actual}" substring="@{versionExpected}"/>
</not>
</condition>
</fail>
</sequential>
</macrodef>
<macrodef name="_javac">
<attribute name="srcDir"/>
<attribute name="destDir"/>
<attribute name="classPathRef"/>
<sequential>
<!-- debuglevel="lines,source" puts line numbers in stack traces -->
<javac
srcdir="@{srcDir}"
destdir="@{destDir}"
classpathref="@{classPathRef}"
fork="true"
debug="on"
debuglevel="lines,source"/>
</sequential>
</macrodef>
<target name="clean" description="clean up">
<delete dir="${build.dir}"/>
<ant dir="examples" target="clean" inheritAll="false"/>
</target>
<target name="bootstrap">
<tstamp/>
<mkdir dir="${build.dir}"/>
<mkdir dir="${classes.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${test.thrift.gen.java.dir}"/>
<mkdir dir="${src.gen.java.dir}"/>
</target>
<target name="init-ivy" depends="bootstrap" unless="init-ivy.complete">
<property name="ivy.settings.file" value="${basedir}/ivysettings.xml"/>
<get src="${maven.repo}/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"
dest="${build.dir}" usetimestamp="true"/>
<taskdef resource="org/apache/ivy/ant/antlib.xml" uri="antlib:org.apache.ivy.ant">
<classpath path="${build.dir}/ivy-${ivy.version}.jar"/>
</taskdef>
<property name="init-ivy.complete" value="true"/>
</target>
<target name="resolve" description="retrieve dependencies with ivy" depends="init-ivy">
<ivy:retrieve sync="true" type="jar"
pattern="${build.dir}/lib/[conf]/[organization]-[artifact]-[revision](-[classifier]).[ext]"/>
<property name="ivy.pom.version" value="${version}"/>
<ivy:makepom ivyfile="${basedir}/ivy.xml"
pomfile="${build.dir}/${jar.name}-${version}.pom"/>
</target>
<target name="report" depends="resolve">
<ivy:report todir="${build.dir}"/>
</target>
<target name="init" depends="bootstrap, init-ivy"/>
<!-- Protobuf generation is required at this time as generated classes are
used directly by elephant-bird. -->
<target name="generate-protobuf" depends="init">
<_check_compiler compiler="protoc"
versionArg="--version"
versionExpected="${protobuf.version.expected}"/>
<apply executable="protoc" failonerror="true" skipemptyfilesets="true" verbose="true">
<arg value="--proto_path=${src.proto.dir}"/>
<arg value="--java_out=${src.gen.java.dir}"/>
<fileset dir="${src.proto.dir}" includes="**/*.proto"/>
</apply>
</target>
<!-- Compilation targets -->
<path id="compile.classpath">
<fileset dir="${compile.lib.dir}"/>
<pathelement location="${classes.dir}"/>
</path>
<target name="compile" depends="init, resolve, generate-protobuf">
<_javac srcDir="${src.gen.java.dir}"
destDir="${classes.dir}"
classPathRef="compile.classpath"/>
<_javac srcDir="${src.java.dir}"
destDir="${classes.dir}"
classPathRef="compile.classpath"/>
</target>
<target name="jar" depends="compile" description="generate the distribution">
<jar jarfile="${jar.file}">
<fileset dir="${classes.dir}"/>
</jar>
</target>
<!-- Test targets -->
<!-- Thrift code generation is required for tests. -->
<target name="generate-thrift" depends="init">
<_check_compiler compiler="thrift"
versionArg="-version"
versionExpected="${thrift.version.expected}"/>
<apply executable="thrift" failonerror="true" skipemptyfilesets="true" verbose="true">
<arg value="--gen"/>
<arg value="java"/>
<arg value="-o"/>
<!-- Thrift creates gen-java in the output directory. -->
<arg value="${test.thrift.gen.java.dir}/.."/>
<fileset dir="${src.thrift.dir}" includes="**/*.thrift"/>
</apply>
</target>
<target name="compile-thrift" depends="generate-thrift">
<_javac srcDir="${test.thrift.gen.java.dir}"
destDir="${classes.dir}"
classPathRef="compile.classpath"/>
</target>
<target name="compile-java-tests" depends="compile, compile-thrift">
<delete dir="${test.build.classes}"/>
<mkdir dir="${test.build.classes}"/>
<path id="compile.java.tests.classpath">
<fileset dir="${test.lib.dir}"/>
<pathelement location="${classes.dir}"/>
</path>
<_javac srcDir="${test.src.dir}"
destDir="${test.build.classes}"
classPathRef="compile.java.tests.classpath"/>
</target>
<target name="test" depends="jar, 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.log.dir" value="${test.log.dir}"/>
<sysproperty key="test.source.dir" value="${test.src.dir}"/>
<sysproperty key="java.library.path" value="${test.library.path}"/>
<classpath>
<fileset dir="${test.lib.dir}"/>
<pathelement location="${classes.dir}"/>
<pathelement location="${test.build.classes}"/>
</classpath>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.log.dir}" unless="testcase">
<fileset dir="${test.src.dir}" includes="**/${test.include}.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>
<!-- Misc. targets -->
<target name="javadoc" depends="generate-protobuf" description="generate documentation">
<delete dir="${javadoc.dir}"/>
<javadoc destdir="${javadoc.dir}"
classpathref="compile.classpath"
additionalparam="-notimestamp">
<fileset dir="${src.java.dir}"/>
<fileset dir="${src.gen.java.dir}"/>
</javadoc>
</target>
<target name="init-maven">
<taskdef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="artifact:org.apache.maven.artifact.ant"
classpath="${test.lib.dir}/org.apache.maven-maven-ant-tasks-${maven-ant-tasks.version}.jar"/>
</target>
<target name="publish" depends="jar, init-maven"
description="publish to the in-git-repo maven repository">
<artifact:deploy file="${jar.file}">
<artifact:remoteRepository url="file://${basedir}/repo"/>
<artifact:pom file="${build.dir}/${jar.name}-${version}.pom"/>
</artifact:deploy>
</target>
<target name="install-local" depends="jar, init-maven"
description="install in your local user maven repository">
<artifact:install file="${jar.file}">
<artifact:pom file="${build.dir}/${jar.name}-${version}.pom"/>
</artifact:install>
</target>
<target name="examples" depends="jar" description="Compile the examples">
<ant dir="examples" inheritAll="false">
<property name="lib.dir" value="${test.lib.dir}"/>
<property name="jar.file" value="${jar.file}"/>
<property name="version" value="${version}"/>
</ant>
</target>
</project>