-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.xml
executable file
·450 lines (367 loc) · 15.8 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
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
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<?xml version="1.0"?>
<!--
/**
* Copyright 2010 Nube Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/
-->
<project name="hiho" default="jar" xmlns:artifact="urn:maven-artifact-ant" xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- Load system-wide and project-wide default properties set by
the user, to avoid needing to override with -D. -->
<property file="${user.home}/build.properties" />
<property file="${basedir}/build.properties" />
<!-- some basic properties -->
<property environment="env" />
<property name="name" value="hiho" />
<property name="Name" value="HIHO" />
<property name="version" value="0.5.0" />
<property name="artifact.name" value="${name}-${version}" />
<property name="dest.jar" value="${artifact.name}.jar" />
<property name="test.jar" value="${name}-test-${version}.jar" />
<!-- locations in the source tree -->
<property name="base.src.dir" location="${basedir}/src" />
<property name="src.dir" location="${base.src.dir}" />
<property name="lib.dir" location="${basedir}/lib" />
<property name="test.dir" location="${basedir}/test" />
<!-- base directory for all build/test process output -->
<property name="build.dir" location="${basedir}/build" />
<!-- compiled classes for the main hiho artifact. -->
<property name="build.classes" location="${build.dir}/classes" />
<property name="dist.dir" location="${build.dir}/${artifact.name}" />
<property name="tar.file" location="${build.dir}/${artifact.name}.tar.gz" />
<property name="build.docs.timestamp" location="${build.dir}/docs.timestamp" />
<property name="integration.dir" location="${basedir}/deploy" />
<!-- compilation -->
<property name="javac.deprecation" value="off" />
<property name="javac.debug" value="on" />
<property name="build.encoding" value="ISO-8859-1" />
<!-- controlling the Hadoop source -->
<!-- valid values for ${hadoop.dist} are 'apache', 'apacheTrunk' etc -->
<property name="hadoop.dist" value="apache" />
<!-- Ivy-based dependency resolution -->
<property name="ivy.dir" location="${basedir}/ivy" />
<property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
<loadproperties srcfile="${ivy.dir}/libraries.properties" />
<property name="ivy.jar" location="${lib.dir}/ivy-${ivy.version}.jar" />
<property name="ivy_repo_url" value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
<property name="mvn_repo_url" value="http://repo2.maven.org/maven2/org/apache/maven/maven-ant-tasks/${mvn.version}/maven-ant-tasks-${mvn.version}.jar" />
<property name="mvn.jar" location="${build.dir}/maven-ant-tasks-${mvn.version}.jar" />
<property name="build.ivy.dir" location="${build.dir}/ivy" />
<property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib" />
<property name="build.ivy.report.dir" location="${build.ivy.dir}/report" />
<property name="redist.ivy.lib.dir" location="${build.ivy.lib.dir}/${name}/redist" />
<!--this is the naming policy for artifacts we want pulled down-->
<property name="ivy.artifact.retrieve.pattern" value="${name}/[conf]/[artifact]-[revision].[ext]" />
<!--property name="hadoop.mirror" value="http://archive.apache.org/dist" /-->
<property name="hadoop.mirror" value="http://www.trieuvan.com/apache/" />
<!-- load ant-contrib tasks to get the "if" task. -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<path id="lib.path">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- The classpath for compiling and running -->
<if>
<isset property="hadoop.home" />
<then>
<path id="compile.classpath">
<pathelement location="${build.classes}" />
<path refid="lib.path" />
<fileset dir="${hadoop.home}">
<include name="hadoop-core-*.jar" />
<include name="hadoop-*-core.jar" />
<include name="hadoop-common-*.jar" />
<include name="hadoop-mapred-*.jar" />
<include name="hadoop-hdfs-*.jar" />
<include name="*hadoop-*-test.jar" />
</fileset>
<fileset dir="${hadoop.home}/lib">
<include name="*.jar" />
</fileset>
<path refid="${name}.hadoop.classpath" />
</path>
</then>
<else>
<if>
<equals arg1="${hadoop.dist}" arg2="apache" />
<then>
<path id="compile.classpath">
<pathelement location="${build.classes}" />
<path refid="lib.path" />
<fileset dir="${build.ivy.lib.dir}/${name}/default/hadoop-${hadoop-core.apache.version}">
<include name="*.jar" />
</fileset>
<fileset dir="${build.ivy.lib.dir}/${name}/default/hadoop-${hadoop-core.apache.version}/lib">
<include name="*.jar" />
</fileset>
<path refid="${name}.hadoop.classpath" />
</path>
</then>
<else>
<path id="compile.classpath">
<pathelement location="${build.classes}" />
<path refid="lib.path" />
<path refid="${name}.hadoop.classpath" />
</path>
</else>
</if>
</else>
</if>
<!-- "init" target used for setup purposes. -->
<target name="init">
<!-- The hadoop.dist property determines which version of Hadoop to
retrieve; this may be "apache", or "apache21". But
multiple of these versions can use the same shim. We set the
hadoop.shim property here, based on that one.
<if>
<equals arg1="${hadoop.dist}" arg2="apache" />
<then>
<property name="hadoop.shim" value="apache" />
<echo message="Hadoop distribution: apache -> apache (trunk) " />
</then>
<elseif>
<equals arg1="${hadoop.dist}" arg2="apache21" />
<then>
<property name="hadoop.shim" value="apache" />
<echo message="Hadoop distribution: apache21 -> apache (0.21)" />
</then>
</elseif>
<elseif>
<equals arg1="${hadoop.dist}" arg2="apache20" />
<then>
<property name="hadoop.shim" value="apache20" />
<echo message="Hadoop distribution: apache20 -> apache (0.20)" />
</then>
</elseif>
<else>
<fail message="Invalid value for hadoop.dist: ${hadoop.dist}" />
</else>
</if>
-->
</target>
<target name="ivy-retrieve-hadoop" depends="ivy-init,ivy-resolve-hadoop">
<if>
<equals arg1="${hadoop.dist}" arg2="local" />
<then>
<!-- Use a local Hadoop distribution. Just retrieve the basic
'common' configuration, and add the Hadoop jars from
the local Hadoop install.
We can't use a subant here, because the refs wouldn't be
preserved when we return to executing this target.
-->
<ivy:resolve settingsRef="${name}.ivy.settings" />
<ivy:retrieve settingsRef="${name}.ivy.settings" pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.hadoop.classpath" />
</then>
<else>
<!-- retrieve hadoop refs normally. -->
<ivy:retrieve settingsRef="${name}.ivy.settings" pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<!--if hadoop is 0.20, we need to untar -->
<if>
<equals arg1="${hadoop.dist}" arg2="apache" />
<then>
<untar src="${build.dir}/ivy/lib/hiho/default/hadoop-${hadoop-core.apache.version}.tar.gz" dest="${build.dir}/ivy/lib/hiho/default/" compression="gzip" />
</then>
</if>
<ivy:cachepath pathid="${name}.hadoop.classpath" />
</else>
</if>
</target>
<target name="ivy-retrieve-hive" depends="ivy-init,ivy-resolve-hive">
<untar src="${build.dir}/ivy/lib/hiho/default/hive-${hive.version}.tar.gz" dest="${build.dir}/ivy/lib/hiho/default/" compression="gzip" />
<ivy:cachepath pathid="${name}.hive.classpath" />
</target>
<target name="makepom">
<ivy:makepom ivyfile="${basedir}/ivy.xml" pomfile="${basedir}/pom.xml" conf="default,runtime">
<mapping conf="default" scope="compile"/>
<mapping conf="runtime" scope="runtime"/>
</ivy:makepom>
</target>
<!-- Compile core classes for the project -->
<target name="compile" depends="init, ivy-retrieve-hadoop,ivy-retrieve-hive,ivy-resolve-pig" description="Compile core classes for the project">
<!-- ensure normal build target dir exists -->
<mkdir dir="${build.classes}" />
<echo message="Class path is " />
<echo message="compile.classpath" />
<!-- Compile the main code. -->
<javac encoding="${build.encoding}" srcdir="${src.dir}" includes="**/*.java" destdir="${build.classes}" debug="${javac.debug}" deprecation="${javac.deprecation}">
<classpath refid="compile.classpath" />
</javac>
</target>
<!-- Compile core classes for the project -->
<target name="compileTest" depends="init, ivy-retrieve-hadoop,compile,ivy-retrieve-hive,ivy-resolve-pig" description="Compile test classes for the project">
<!-- ensure normal build target dir exists -->
<mkdir dir="${build.classes}" />
<!-- Compile the main code. -->
<javac encoding="${build.encoding}" srcdir="${test.dir}" includes="**/*.java" destdir="${build.classes}" debug="${javac.debug}" deprecation="${javac.deprecation}">
<classpath refid="compile.classpath" />
</javac>
</target>
<!--target name="test">
<junit fork="yes" haltonfailure="yes">
<classpath refid="test.classpath" />
<formatter type="plain" usefile="false" />
<batchtest>
<fileset dir="${build.classes}/test" includes="**/Test*.class" />
</batchtest>
</junit>
</target>
<target name="jarTest" depends="compile,compileTest" description="Create test jar">
<jar jarfile="${build.dir}/${test.jar}" basedir="${build.classes}" />
</target-->
<target name="jar" depends="compile,compileTest" description="Create main jar">
<jar jarfile="${build.dir}/${dest.jar}" basedir="${build.classes}" />
</target>
<target name="clean" description="Clean build target files">
<delete dir="${build.dir}" />
<delete dir="${integration.dir}" />
</target>
<target name="clean-cache" description="Remove cached dependencies">
<delete dir="${user.home}/.ivy2/cache/org.apache.hadoop" />
<delete file="${ivy.jar}" />
</target>
<target name="veryclean" depends="clean,clean-cache" description="Clean build and remove cached dependencies">
</target>
<!-- Downloads the ivy jar itself. -->
<target name="ivy-download" unless="offline">
<mkdir dir="${lib.dir}" />
<get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true" />
</target>
<target name="ivy-init-antlib" depends="ivy-download" unless="ivy.found">
<typedef uri="antlib:org.apache.ivy.ant" onerror="fail" loaderRef="ivyLoader">
<classpath>
<pathelement location="${ivy.jar}" />
</classpath>
</typedef>
<fail>
<condition>
<not>
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache" />
</not>
</condition>
You need Apache Ivy 2.0 or later from http://ant.apache.org/
It could not be loaded from ${ivy_repo_url}
</fail>
</target>
<target name="ivy-init" depends="ivy-init-antlib" unless="ivy.configured">
<ivy:configure settingsid="${name}.ivy.settings" file="${ivysettings.xml}" />
<property name="ivy.configured" value="true" />
</target>
<!-- retrieve ivy-managed artifacts for the compile configuration -->
<target name="ivy-resolve-common" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" />
</target>
<target name="ivy-retrieve-common" depends="ivy-resolve-common">
<ivy:retrieve settingsRef="${name}.ivy.settings" pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.common.classpath" />
</target>
<!-- retrieve ivy-managed artifacts from the Hadoop distribution -->
<target name="ivy-resolve-hadoop" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" />
</target>
<target name="ivy-resolve-hive" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" />
</target>
<target name="ivy-resolve-pig" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" />
</target>
<!-- retrieve ivy-managed artifacts for the redist configuration -->
<target name="ivy-resolve-redist" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" conf="redist" />
</target>
<target name="ivy-retrieve-redist" depends="ivy-resolve-redist">
<ivy:retrieve settingsRef="${name}.ivy.settings" pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.redist.classpath" conf="redist" />
</target>
<target name="package" depends="deploy,compile,ivy-retrieve-redist" description="Create a redistributable package">
<mkdir dir="${dist.dir}" />
<!-- copy in the build artifact -->
<copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
<fileset dir="${build.dir}">
<include name="${dest.jar}" />
</fileset>
</copy>
<!-- copy in various components of the initial source layout
so that the redistributable can bootstrap itself. -->
<copy todir="${dist.dir}" includeEmptyDirs="false" flatten="false">
<fileset dir="${basedir}">
<include name="**/*" />
<exclude name="build/**" />
<exclude name="lib/**" />
<exclude name="tags" />
<exclude name=".project" />
<exclude name=".classpath" />
<exclude name=".git/**" />
<exclude name="ivy/ivy*jar" />
</fileset>
</copy>
<!-- copy the dependency libraries from ivy into the output lib dir
<mkdir dir="${dist.dir}/lib"/>
<copy todir="${dist.dir}/lib" includeEmptyDirs="false" flatten="true">
<fileset dir="${redist.ivy.lib.dir}">
<include name="**/*.jar" />
</fileset>
</copy>
-->
<copy todir="${dist.dir}/lib" includeEmptyDirs="false">
<fileset dir="${lib.dir}">
<include name="**/*" />
</fileset>
</copy>
</target>
<target name="tar" depends="package" description="Create release tarball">
<tar compression="gzip" longfile="gnu" destfile="${tar.file}">
<tarfileset dir="${build.dir}" mode="664">
<exclude name="${artifact.name}/bin/*" />
<exclude name="${artifact.name}/**/*.sh" />
<include name="${artifact.name}/**" />
</tarfileset>
<tarfileset dir="${build.dir}" mode="755">
<include name="${artifact.name}/bin/*" />
<include name="${artifact.name}/**/*.sh" />
</tarfileset>
</tar>
</target>
<target name="deploy" depends="clean,jar" description="Create a jar with all dependencies bundled in">
<mkdir dir="${integration.dir}" />
<!-- copy in the build artifact -->
<copy tofile="${integration.dir}/${name}.jar" includeEmptyDirs="false" flatten="true" >
<fileset dir="${build.dir}">
<include name="${dest.jar}" />
</fileset>
</copy>
<!-- copy the dependency libraries from ivy into the output lib dir -->
<mkdir dir="${integration.dir}/lib"/>
<copy todir="${integration.dir}/lib" includeEmptyDirs="false" flatten="true">
<fileset dir="${build.ivy.lib.dir}/${name}/default/">
<include name="hive*/lib/hive*.jar" />
</fileset>
</copy>
<copy todir="${integration.dir}/lib" includeEmptyDirs="false">
<fileset dir="${lib.dir}">
<include name="mysql-connector*jar" />
<include name="partner*jar" />
<include name="pig*jar" />
<include name="wsc*jar" />
</fileset>
</copy>
<unjar src="${integration.dir}/${name}.jar" dest="${integration.dir}"/>
<delete file="${integration.dir}/${name}.jar"/>
<jar jarfile="${integration.dir}/${dest.jar}" basedir="${integration.dir}" />
</target>
</project>