-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-common.xml
399 lines (350 loc) · 19 KB
/
build-common.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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?xml version="1.0" encoding="UTF-8"?>
<project name="gora-common" xmlns:ivy="antlib:org.apache.ivy.ant">
<property name="version" value="0.1" />
<property name="final.name" value="${ant.project.name}-${version}" />
<property name="year" value="2008" />
<property name="module.version.target" value="${version}" />
<property name="module.name" value="${ant.project.name}-${version}"/>
<!-- Load all the default properties, and any the user wants -->
<!-- to contribute (without having to type -D or edit this file -->
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
<property file="${basedir}/default.properties" />
<property name="project.dir" value="${basedir}/.."/>
<property name="lib.dir" value="${basedir}/lib" />
<property name="lib-ext.dir" value="${basedir}/lib-ext" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="src.dir" value="${basedir}/src/main/java" />
<property name="conf.dir" value="${basedir}/conf" />
<property name="jar.file" value="${build.dir}/${module.name}.jar" />
<property name="job.file" value="${build.dir}/${module.name}.job" />
<property name="dist.dir" value="${build.dir}/${final.name}" />
<property name="examples.src.dir" value="${basedir}/src/examples/java" />
<property name="examples.build.dir" value="${build.dir}/examples" />
<property name="examples.build.classes.dir" value="${examples.build.dir}/classes" />
<property name="test.src.dir" value="${basedir}/src/test/java" />
<property name="test.conf.dir" value="${basedir}/src/test/conf" />
<property name="test.build.dir" value="${build.dir}/test" />
<property name="test.build.data" value="${test.build.dir}/data" />
<property name="test.build.classes.dir" value="${test.build.dir}/classes" />
<property name="test.jar.file" value="${build.dir}/${ant.project.name}-test-${version}.jar" />
<property name="test.lib.dir" value="${basedir}/src/test/lib"/>
<property name="test.log.dir" value="${test.build.dir}/logs"/>
<property name="test.include" value="Test*"/>
<property name="test.junit.output" value="no"/>
<property name="test.junit.timeout" value="3600000"/>
<property name="test.junit.output.format" value="plain"/>
<property name="test.junit.fork.mode" value="perTest" />
<property name="test.junit.printsummary" value="yes" />
<property name="test.junit.haltonfailure" value="no" />
<property name="test.junit.maxmemory" value="512m" />
<property name="build.encoding" value="UTF-8" />
<property name="javac.debug" value="on" />
<property name="javac.optimize" value="on" />
<property name="javac.deprecation" value="off" />
<property name="javac.version" value="1.6" />
<!-- Include project's build file -->
<import file="${project.dir}/build.xml"/>
<!--<ivy:settings file="${basedir}/ivy/ivysettings.xml" />-->
<!-- ====================================================== -->
<!-- path: classpath -->
<!-- ====================================================== -->
<path id="classpath">
<pathelement location="${build.classes.dir}"/>
<pathelement location="${conf.dir}"/>
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- the unit test classpath: uses test.src.dir for configuration -->
<path id="test.classpath">
<pathelement location="${examples.build.classes.dir}"/>
<pathelement location="${conf.dir}"/>
<pathelement location="${test.build.classes.dir}" />
<pathelement location="${test.src.dir}"/>
<pathelement location="${build.dir}"/>
<pathelement location="${test.conf.dir}"/>
<path refid="classpath"/>
</path>
<!-- ====================================================== -->
<!-- target: init -->
<!-- ====================================================== -->
<target name="init" depends="ivy-init">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.classes.dir}"/>
<mkdir dir="${examples.build.dir}"/>
<mkdir dir="${examples.build.classes.dir}"/>
<mkdir dir="${test.build.dir}"/>
<mkdir dir="${test.build.classes.dir}"/>
<copy todir="${conf.dir}" verbose="true" failonerror="false">
<fileset dir="${conf.dir}" includes="**/*.template"/>
<mapper type="glob" from="*.template" to="*"/>
</copy>
</target>
<!-- ====================================================== -->
<!-- target: compile -->
<!-- ====================================================== -->
<target name="compile" depends="init, resolve">
<javac
encoding="${build.encoding}"
srcdir="${src.dir}"
includes="**/*.java"
destdir="${build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
<classpath refid="classpath"/>
</javac>
</target>
<!-- ====================================================== -->
<!-- target: compile-examples -->
<!-- ====================================================== -->
<target name="compile-examples" depends="compile">
<javac
encoding="${build.encoding}"
srcdir="${examples.src.dir}"
includes="**/*.java"
destdir="${examples.build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
<classpath refid="classpath"/>
</javac>
</target>
<!-- ================================================================== -->
<!-- target: compile-test -->
<!-- ================================================================== -->
<target name="compile-test" depends="compile-examples, resolve-test">
<javac
encoding="${build.encoding}"
srcdir="${test.src.dir}"
includes="**/*.java"
destdir="${test.build.classes.dir}"
debug="${javac.debug}"
optimize="${javac.optimize}"
target="${javac.version}"
source="${javac.version}"
deprecation="${javac.deprecation}">
<classpath refid="test.classpath"/>
</javac>
</target>
<!-- ================================================================== -->
<!-- target: jar -->
<!-- ================================================================== -->
<target name="jar" depends="compile, version" description="--> make a jar file for this project">
<jar destfile="${jar.file}">
<fileset dir="${build.classes.dir}" />
<!--<zipfileset dir="${conf.dir}" excludes="*.template"/>-->
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Version" value="${version}" />
</manifest>
</jar>
</target>
<!-- ================================================================== -->
<!-- target: test-jar -->
<!-- ================================================================== -->
<target name="test-jar" depends="version, compile-test, jar" description="--> make a jar file for this project">
<jar destfile="${test.jar.file}">
<fileset dir="${examples.build.classes.dir}" />
<fileset dir="${test.build.classes.dir}" />
<fileset dir="${test.conf.dir}" excludes="*.template" />
<!--<zipfileset dir="${conf.dir}" excludes="*.template"/>-->
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Version" value="${version}" />
</manifest>
</jar>
</target>
<target name="jar-snapshot" description="copies the jar files to append timestamp to artifact name">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<copy file="${jar.file}" tofile="${build.dir}/${module.name}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${module.name}-${now}.jar"/>
</target>
<target name="test-jar-snapshot" description="copies the jar files to append timestamp to artifact name">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<copy file="${jar.file}" tofile="${build.dir}/${module.name}-${now}.jar"/>
<copy file="${test.jar.file}" tofile="${build.dir}/${ant.project.name}-test-${version}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${module.name}-${now}.jar"/>
<echo message="New snapshot jar file copied to ${build.dir}/${ant.project.name}-test-${version}-${now}.jar"/>
</target>
<!-- ================================================================== -->
<!-- target: job -->
<!-- ================================================================== -->
<target name="job" depends="compile" description="--> make a job file for running on hadoop">
<jar destfile="${job.file}">
<fileset dir="${build.classes.dir}" />
<zipfileset dir="conf" excludes="*.template" />
<zipfileset dir="${lib.dir}" prefix="lib" includes="**/*.jar" excludes="hadoop-*.jar" followsymlinks="true"/>
<zipfileset dir="${lib.dir}" prefix="lib" includes="hadoop-gpl-compression*.jar" followsymlinks="true"/>
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Build-Version" value="${version}" />
</manifest>
</jar>
</target>
<!-- ================================================================== -->
<!-- target: test -->
<!-- ================================================================== -->
<target name="test" depends="compile-test" description="Run core unit tests">
<delete dir="${test.build.data}"/>
<mkdir dir="${test.build.data}"/>
<delete dir="${test.log.dir}"/>
<mkdir dir="${test.log.dir}"/>
<junit showoutput="${test.junit.output}"
printsummary="${test.junit.printsummary}"
haltonfailure="${test.junit.haltonfailure}"
fork="yes"
forkmode="${test.junit.fork.mode}"
maxmemory="${test.junit.maxmemory}"
dir="${basedir}" timeout="${test.junit.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.build.data" value="${test.build.data}"/>
<sysproperty key="hadoop.log.dir" value="${test.log.dir}"/>
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.build.dir}" unless="testcase">
<fileset dir="${test.src.dir}"
includes="**/${test.include}.java"
excludes="**/${test.exclude}.java" />
</batchtest>
<batchtest todir="${test.build.dir}" if="testcase">
<fileset dir="${test.src.dir}" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<!-- ================================================================== -->
<!-- target: resolve -->
<!-- ================================================================== -->
<target name="resolve" depends="clean-lib" description="--> resolve and retrieve dependencies with ivy">
<mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
<!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
<ivy:resolve file="${ivy.dir}/${ivy.file}" conf="compile" log="download-only"/>
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" symlink="true" log="quiet" conf="compile"/>
<!-- copy the libs in lib-ext, which are not ivy enabled, should change in the future -->
<copy todir="${lib.dir}/" failonerror="false">
<fileset dir="${lib-ext.dir}" includes="**/*.jar"/>
</copy>
</target>
<!-- ================================================================== -->
<!-- target: resolve-test -->
<!-- ================================================================== -->
<target name="resolve-test" depends="clean-lib" description="--> resolve and retrieve dependencies with ivy">
<mkdir dir="${lib.dir}"/> <!-- not usually necessary, ivy creates the directory IF there are dependencies -->
<!-- the call to resolve is not mandatory, retrieve makes an implicit call if we don't -->
<ivy:resolve file="${ivy.dir}/${ivy.file}" conf="test" log="download-only"/>
<ivy:retrieve pattern="${lib.dir}/[artifact]-[revision].[ext]" symlink="true" log="quiet" conf="test"/>
<!-- copy the libs in lib-ext, which are not ivy enabled, should change in the future -->
<copy todir="${lib.dir}/" failonerror="false">
<fileset dir="${lib-ext.dir}" includes="**/*.jar"/>
</copy>
</target>
<!-- ================================================================== -->
<!-- target: report -->
<!-- ================================================================== -->
<target name="report" depends="resolve" description="--> generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: ivy-new-version -->
<!-- ================================================================== -->
<target name="ivy-new-version" depends="" unless="ivy.new.revision">
<!-- default module version prefix value -->
<property name="module.version.prefix" value="${module.version.target}-dev-b" />
<!-- asks to ivy an available version number -->
<ivy:info file="${ivy.dir}/${ivy.file}" />
<ivy:buildnumber organisation="${ivy.organisation}" module="${ivy.module}"
revision="${module.version.prefix}" defaultBuildNumber="1" revSep=""/>
</target>
<!-- ================================================================== -->
<!-- target: local-version -->
<!-- ================================================================== -->
<target name="local-version">
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<property name="ivy.new.revision" value="${module.version.target}-local-${now}"/>
</target>
<!-- ================================================================== -->
<!-- target: version -->
<!-- ================================================================== -->
<target name="version" depends="ivy-new-version">
<!-- create version file in classpath for later inclusion in jar -->
<mkdir dir="${build.classes.dir}"/>
<echo message="version=${ivy.new.revision}" file="${build.classes.dir}/${ant.project.name}.properties" append="false" />
<!-- load generated version properties file -->
<property file="${classes.dir}/${ant.project.name}.properties" />
</target>
<!-- ================================================================== -->
<!-- target: publish -->
<!-- ================================================================== -->
<target name="publish" depends="version, clean-build, jar" description="--> publish this project in the ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact].[ext]"
resolver="shared"
pubrevision="${version}"
status="release"/>
<echo message="project ${ant.project.name} released with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: publish-local -->
<!-- ================================================================== -->
<target name="publish-local" depends="local-version, jar" description="--> publish this project in the local ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact]-${version}.[ext]"
resolver="local"
pubrevision="${version}"
pubdate="${now}"
status="integration"
forcedeliver="true"
overwrite="true"
conf="compile"
/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: publish-local-test -->
<!-- ================================================================== -->
<target name="publish-local-test" depends="local-version, test-jar" description="--> publish this project in the local ivy repository">
<ivy:publish artifactspattern="${build.dir}/[artifact]-${version}.[ext]"
resolver="local"
pubrevision="${version}"
pubdate="${now}"
status="integration"
forcedeliver="true"
overwrite="true"
/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<!-- ================================================================== -->
<!-- target: clean-local -->
<!-- ================================================================== -->
<target name="clean-local" depends="" description="--> cleans the local repository for the current module">
<ivy:info file="${ivy.dir}/${ivy.file}" />
<delete dir="${ivy.local.default.root}/${ivy.organisation}/${ivy.module}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean-lib -->
<!-- ================================================================== -->
<target name="clean-lib" description="--> clean the project libraries directory (dependencies)">
<delete includeemptydirs="true" dir="${lib.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean-build -->
<!-- ================================================================== -->
<target name="clean-build" description="--> clean the project built files">
<delete includeemptydirs="true" dir="${build.dir}"/>
</target>
<!-- ================================================================== -->
<!-- target: clean -->
<!-- ================================================================== -->
<target name="clean" depends="clean-build, clean-lib" description="--> clean the project" />
</project>