-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
executable file
·260 lines (227 loc) · 10.1 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
<!-- ===================================================================
== Common Build File - This contains all targets for common running using
== Ant with compilation by Maven and also for those targets which use
== hadoop map/reduce
==
== =================================================================== -->
<project name="common-build" default="compile" xmlns:artifact="urn:maven-artifact-ant">
<property name="inheritRefs" value="true" />
<!-- Property to pre-pend value at beginning of Hadoop Jar classpath -->
<property name="jar.classpath.head" value="" />
<!-- =================================================================== -->
<!-- Variable declaration -->
<!-- =================================================================== -->
<property name="debug" value="on" />
<property name="deprecation" value="off" />
<property name="optimize" value="on" />
<property name="source_java_version" value="1.5" />
<property name="target_java_version" value="1.5" />
<property environment="env" />
<property name="jarDir" value="build" />
<property name="jarVersions" value="jars" />
<property name="dataDir" value="data" />
<property name="configDir" value="config" />
<property name="resourceDir" value="src/main/resources" />
<property name="name" value="${ant.project.name}"/>
<property name="depJarFile" value="${jarVersions}/${name}.jar" />
<property name="testJarFile" value="${jarVersions}/${name}-test.jar" />
<property name="uberJarFile" value="${jarVersions}/${name}-all.jar" />
<property name="mavenJarFile" value="${jarVersions}/${name}-maven.jar" />
<property name="mavenTestJarFile" value="${jarVersions}/${name}-maven-test.jar" />
<property name="hadoop" value="${env.HADOOP_HOME}/bin/hadoop"/>
<!-- ================================================================= -->
<!-- Maven Build Environment -->
<!-- ================================================================= -->
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpath="../ant-maven-build/lib/maven-ant-tasks-2.1.0.jar"/>
<artifact:pom id="pomfile" file="pom.xml" inheritAllProperties="true"/>
<artifact:dependencies
pathId="runtime.classpath" filesetId="runtime.fileset"
pomrefid="pomfile" cacheDependencyRefs="false"
useScope="runtime"/>
<!-- only needed if compiling [but should not be necessary since maven used to compile -->
<target name="mvn-compile" unless="compile.classpath">
<artifact:dependencies
pathId="compile.classpath" filesetId="compile.fileset"
pomrefid="pomfile" cacheDependencyRefs="false"
useScope="compile"/>
</target>
<artifact:dependencies
pathId="test.classpath" filesetId="test.fileset"
pomrefid="pomfile" cacheDependencyRefs="false"
useScope="test"/>
<!-- ================================================================= -->
<!-- Set paths based on POM file settings -->
<!-- ================================================================= -->
<!--
<property name="targetDir" value="${pomfile.build.directory}"/>
<property name="srcDir" value="${pomfile.build.sourceDirectory}" />
<property name="testSrcDir" value="${pomfile.build.testSourceDirectory}"/>
<property name="buildDir" value="${pomfile.build.outputDirectory}" />
<property name="testBuildDir" value="${pomfile.build.outputDirectory}" />
-->
<!-- Must hard define as ${project.basedir} is not resolving
-->
<property name="targetDir" value="target"/>
<property name="srcDir" value="src" />
<property name="testSrcDir" value="${srcDir}/test" />
<property name="buildDir" value="target/classes" />
<property name="testBuildDir" value="target/test-classes" />
<!-- ================================================================ -->
<!-- Define which JAR file to use for Hadoop Jobs -->
<!-- ================================================================ -->
<property name="hadoopJarFile" value="${depJarFile}"/>
<target name="hadoopJar" depends="check-hadoop-jar-exists" unless="hadoop.jar.exists">
<antcall target="jars"/>
</target>
<target name="check-hadoop-jar-exists" unless="hadoop.jar.exists">
<available property="hadoop.jar.exists" file="${hadoopJarFile}"/>
</target>
<!-- ================================================================= -->
<!-- Setup all encompassing classpath for running -->
<!-- ================================================================= -->
<path id="classpath">
<pathelement path="${buildDir}"/>
<pathelement path="${testBuildDir}"/>
<pathelement path="." />
<fileset refid="runtime.fileset"/>
<fileset refid="test.fileset"/>
<pathelement path="${env.HBASE_HOME}/conf/hbase-site.xml" />
<pathelement path="${env.HBASE_HOME}/conf/" />
<pathelement path="${env.HADOOP_HOME}/conf/" />
</path>
<path id="project.class.path">
<path path="${runtime-classpath}"/>
</path>
<!-- ==================================================================== -->
<!-- Build Targets (No op) -->
<!-- ==================================================================== -->
<target name="install">
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpath="lib/maven-ant-tasks-2.1.0.jar"/>
<artifact:mvn pom="pom.xml">
<arg value="install"/>
</artifact:mvn>
</target>
<target name="compile"/>
<target name="compileTests"/>
<!-- =================================================================== -->
<!-- Jar Targets -->
<!-- =================================================================== -->
<target name="prepareJar">
<!-- <delete dir="${jarDir}"/> -->
<mkdir dir="${jarDir}" />
<mkdir dir="${jarDir}/lib" />
<mkdir dir="${jarVersions}" />
<copy todir="${jarDir}/conf" overwrite="true" failonerror="false">
<fileset dir="${configDir}" />
<fileset dir="${resourceDir}" />
</copy>
</target>
<target name="jars" depends="prepareJar">
<copy todir="${jarDir}/lib" flatten="true" overwrite="false" verbose="false">
<fileset refid="runtime.fileset"/>
</copy>
<unjar dest="${jarDir}" overwrite="false">
<fileset dir="${jarDir}/lib" includes="*reconcile*.jar"/>
<fileset dir="${jarDir}/lib" includes="*trinidad*.jar"/>
</unjar>
<!-- make sure local build dir is put in last to overwrite possible contents of jar -->
<copy todir="${jarDir}" overwrite="false" failonerror="false">
<fileset dir="${buildDir}" includes="**/*" />
</copy>
<fileset id="jar.lib.fileset" dir="${jarDir}" includes="lib/*.jar"/>
<property name="jar.lib.classpath" refid="jar.lib.fileset"/>
<jar destfile="${depJarFile}" basedir="${jarDir}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Class-Path" value="${jar.classpath.head}${jar.lib.classpath}"/>
</manifest>
</jar>
</target>
<target name="testjar" depends="prepareJar">
<copy todir="${jarDir}/lib" flatten="true" overwrite="true" verbose="false">
<fileset refid="test.fileset"/>
<fileset refid="runtime.fileset"/>
</copy>
<!-- make sure local build dir is put in last to overwrite possible contents of jar -->
<copy todir="${jarDir}" overwrite="true" failonerror="false">
<fileset dir="${buildDir}" includes="**/*" />
<fileset dir="${testBuildDir}" includes="**/*" />
</copy>
<fileset id="jar.lib.fileset" dir="${jarDir}" includes="lib/*.jar"/>
<property name="jar.lib.classpath" refid="jar.lib.fileset"/>
<jar destfile="${testJarFile}" basedir="${jarDir}">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Class-Path" value="${jar.classpath.head}${jar.lib.classpath}"/>
</manifest>
</jar>
</target>
<target name="uberjar" depends="prepareJar">
<copy todir="${jarDir}" overwrite="true">
<fileset dir="${buildDir}" />
</copy>
<unjar dest="${jarDir}" overwrite="true">
<fileset refid="runtime.fileset"/>
</unjar>
<jar destfile="${uberJarFile}" basedir="${jarDir}"/>
</target>
<!-- ================================================================== -->
<!-- Clean Targets -->
<!-- ================================================================== -->
<target name="clean">
<delete>
<fileset dir="./" includes="**/*~" defaultexcludes="no" />
<fileset dir="./" includes="**/*.log" />
</delete>
<delete dir="${buildDir}" />
</target>
<target name="cleanAll" depends="clean">
<delete>
<fileset dir="${jarVersions}" includes="**/*.jar" defaultexcludes="no" />
</delete>
</target>
<target name="echo">
<property name="myClassPath" refid="classpath"/>
<echo> Classpath:${myClassPath}</echo>
<echo> Base build dir:${targetDir}</echo>
<echo>Build class dir:${buildDir}</echo>
<echo> Src dir:${srcDir}</echo>
<echo> Test Src dir:${testSrcDir}</echo>
<echo> Dep Jar File:${depJarFile}</echo>
<echo> Test Jar File:${testJarFile}</echo>
<echo> Uber Jar File:${uberJarFile}</echo>
</target>
<!-- =================================================================== -->
<!-- Test Targets -->
<!-- =================================================================== -->
<target name="test">
<property name="test.outputDir" value="test-results" />
<property name="test.pattern" value="**/*Test.class" />
<mkdir dir="${test.outputDir}" />
<junit errorproperty="failed" failureproperty="failed" printsummary="on" fork="yes">
<classpath refid="classpath" />
<jvmarg value="-Xmx512m"/>
<jvmarg value="-Dtest.argument.one=${test.argument.one}"/>
<formatter type="brief" usefile="false" />
<formatter type="xml" />
<batchtest todir="${test.outputDir}">
<fileset dir="${testBuildDir}" includes="${test.pattern}"/>
</batchtest>
</junit>
<fail if="failed" message="Test cases failed" />
</target>
<target name="hadoopTest" depends="testjar" description="Junit Test run under Map/Reduce">
<property name="input" value="reconcile.hbase.mapreduce.KeyListInputFormatTests"/>
<echo>Test Class: ${input}</echo>
<exec executable="${hadoop}" spawn="false">
<arg value="jar" />
<arg value="${testJarFile}" />
<arg value="${input}" />
</exec>
</target>
</project>