forked from pentaho/pentaho-hadoop-shims
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-shims-build.xml
323 lines (291 loc) · 13.5 KB
/
common-shims-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
<!--===========================================================================
This is the common build file for all shim implementation projects. This
requires the api project to be jar'd up first; it is directly referenced.
See ../build-res/subfloor.xml for more details
============================================================================-->
<project name="common-shims-build" xmlns:ivy="antlib:org.apache.ivy.ant">
<import file="build-res/subfloor-pkg.xml" />
<property name="common.dir" value="../common" />
<property name="api.dist.dir" value="../api/dist" description="Distrbution directory for the api project. This is where the api jar will be referenced from." />
<property name="lib.provided.dir" value="lib-provided" description="Ivy dependencies of 'provided' configuration are placed here"/>
<property name="lib.pmr.dir" value="lib/pmr" description="Ivy dependencies of 'pmr' configuration are placed here. Placed under lib/ so they are packaged that way."/>
<property name="lib.client.dir" value="lib/client" description="Ivy dependencies of 'client' configuration are placed here. Placed under lib/ so they are packaged that way."/>
<property name="src.common.dir" value="${common.dir}/src" description="Source files that are common to all shims"/>
<property name="classes.common-mapred.dir" value="${bin.dir}/classes-mapred" description="Common mapred source files are compiled into here" />
<property name="src.common-mapred.dir" value="${common.dir}/src-mapred" description="Common mapred sources" />
<property name="testsrc.common.dir" value="${common.dir}/test-src" description="Common test sources" />
<property name="package.common.resdir" value="${common.dir}/package-res" description="Common package resources" />
<property name="ivy.artifact.mapred.id" value="${ivy.artifact.id}-mapred" description="Name of artifact id for the mapred jar" />
<property name="mapred.artifact.name" value="${ivy.artifact.mapred.id}-${project.revision}.jar" description="Name of the mapred jar file to create"/>
<property name="hbase-comparators.artifact.name" value="${ivy.artifact.id}-hbase-comparators-${project.revision}.jar" description="Name of the mapred jar file to create"/>
<!-- Setup the compile classpath to include the provided jars and the api jar -->
<path id="classpath">
<fileset dir="${devlib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset file="${api.dist.dir}/pentaho-hadoop-shims-api-${project.revision}.jar"/>
<fileset dir="${lib.provided.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- Setup the classpath used for testing to include the provided jars -->
<path id="test.classpath">
<fileset dir="${devlib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
<fileset file="${api.dist.dir}/pentaho-hadoop-shims-api-${project.revision}.jar"/>
<fileset dir="${lib.provided.dir}">
<include name="**/*.jar" />
</fileset>
<fileset dir="${testlib.dir}">
<include name="**/*.jar" />
</fileset>
<pathelement path="${testclasses.dir}" />
<pathelement path="${classes.dir}" />
<pathelement path="${classes.common-mapred.dir}" />
</path>
<!-- override init so we can create our mapred.classes.dir -->
<target name="init" depends="subfloor.init">
<mkdir dir="${classes.common-mapred.dir}" />
</target>
<!--
resolve related targets so we can resolve "provided" jars separate from
normal ones so they don't get automatically packaged in with the archives.
-->
<target name="clean-jars" depends="subfloor.clean-jars">
<delete dir="${lib.provided.dir}"/>
</target>
<!-- Resolve provided dependencies to a separate directory -->
<target name="resolve-default" depends="subfloor.resolve-default">
<ivy:resolve file="${ivyfile}" conf="provided" />
<ivy:retrieve conf="provided" pattern="${lib.provided.dir}/[module]-[revision](-[classifier]).[ext]" symlink="${ivy.use.symlinks.internal}" />
<ivy:resolve file="${ivyfile}" conf="pmr" />
<ivy:retrieve conf="pmr" pattern="${lib.pmr.dir}/[module]-[revision](-[classifier]).[ext]" symlink="${ivy.use.symlinks.internal}" />
<ivy:resolve file="${ivyfile}" conf="client" />
<ivy:retrieve conf="client" pattern="${lib.client.dir}/[module]-[revision](-[classifier]).[ext]" symlink="${ivy.use.symlinks.internal}" />
</target>
<!-- Override compile.compile to include common source -->
<target name="compile.compile" depends="init, compile-mapred">
<javac destdir="${classes.dir}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
fork="true"
memorymaximumsize="${javac.maxmemory}"
source="${javac.source}"
target="${javac.target}">
<classpath>
<path refid="classpath" />
<path location="${classes.common-mapred.dir}" />
</classpath>
<src path="${src.dir}" />
<src path="${src.common.dir}" />
</javac>
</target>
<!-- Compile the mapreduce source into a separate output directory so it can be independently packaged -->
<target name="compile-mapred" depends="init">
<javac destdir="${classes.common-mapred.dir}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
fork="true"
source="${javac.source}"
target="${javac.target}">
<classpath>
<path refid="classpath"/>
</classpath>
<src path="${src.common-mapred.dir}" />
</javac>
<copy todir="${classes.common-mapred.dir}" flatten="false">
<fileset dir="${src.common-mapred.dir}" excludes="**/*.java" />
</copy>
</target>
<!-- Copy additional resources into bin directory -->
<target name="compile.res_copy" depends="subfloor.compile.res_copy">
<if>
<not>
<isset property="jar.include.source" />
</not>
<then>
<copy todir="${classes.dir}" flatten="false">
<fileset dir="${src.common.dir}" excludes="**/*.java" />
<fileset dir="${src.common-mapred.dir}" excludes="**/*.java" />
</copy>
</then>
</if>
</target>
<!-- Compile the common tests too -->
<target name="compile-tests" depends="subfloor.compile-tests">
<javac destdir="${testclasses.dir}"
debug="true"
optimize="false"
source="${javac.source}"
target="${javac.target}"
fork="true">
<src path="${testsrc.common.dir}" />
<classpath refid="test.classpath" />
</javac>
<!-- Copy the non-java files from the source directory to the test classes directory -->
<copy todir="${testclasses.dir}">
<fileset dir="${testsrc.dir}">
<exclude name="**/*.java" />
</fileset>
<fileset dir="${testsrc.common.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
</target>
<!-- Instrument the mapred classes too -->
<target name="cobertura.instrument-classes" depends="cobertura.clean-instrumented-classes,install-cobertura,compile">
<cobertura-instrument todir="${instrumented.classes.dir}" datafile="${cobertura.data.dir}/cobertura.ser">
<ignore regex="org.apache.log4j.*" />
<fileset dir="${classes.dir}">
<!--
Instrument all the application classes, but
don't instrument the test classes.
-->
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
<fileset dir="${classes.common-mapred.dir}">
<!--
Instrument all the application classes, but
don't instrument the test classes.
-->
<include name="**/*.class" />
<exclude name="**/*Test.class" />
</fileset>
</cobertura-instrument>
</target>
<!-- Run normal and common tests -->
<target name="test" depends="compile,compile-tests,init-test-reports" description="Compiles and runs unit tests">
<junit maxmemory="${junit.maxmemory}"
fork="yes"
failureProperty="test.failed"
haltonfailure="${junit.haltonfailure}"
printsummary="yes">
<sysproperty key="java.awt.headless" value="${headless.unittest}" />
<syspropertyset>
<propertyref prefix="junit.sysprop." />
<mapper type="glob" from="junit.sysprop.*" to="*"/>
</syspropertyset>
<classpath refid="test.classpath" />
<formatter type="xml" />
<test name="${testcase}" todir="${testreports.xml.dir}" if="testcase" />
<batchtest fork="yes" todir="${testreports.xml.dir}" unless="testcase">
<fileset dir="${testsrc.dir}" casesensitive="yes">
<include name="**/*Test.java" />
</fileset>
<fileset dir="${testsrc.common.dir}" casesensitive="yes">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreports.html.dir}">
<fileset dir="${testreports.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${testreports.html.dir}" />
</junitreport>
</target>
<!-- Run normal and common tests -->
<target name="cobertura.test-instrumented"
depends="init-test-reports,install-cobertura,compile,compile-tests,cobertura.instrument-classes">
<mkdir dir="${instrumented.classes.dir}" />
<path id="cobertura.classpath">
<fileset dir="${subfloor.resources.dir}/cobertura">
<include name="*.jar" />
</fileset>
</path>
<junit fork="yes"
maxmemory="${junit.maxmemory}"
failureProperty="test.failed"
haltonfailure="${junit.haltonfailure}">
<sysproperty key="java.awt.headless" value="${headless.unittest}" />
<!-- Specify the name of the coverage data file to use. -->
<sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.data.dir}/cobertura.ser" />
<syspropertyset>
<propertyref prefix="junit.sysprop." />
<mapper type="glob" from="junit.sysprop.*" to="*"/>
</syspropertyset>
<!--
Note the classpath order: instrumented classes are before the
original (uninstrumented) classes. This is important.
-->
<classpath location="${instrumented.classes.dir}" />
<classpath location="${classes.dir}" />
<classpath location="${classes.common-mapred.dir}" />
<classpath location="${testclasses.dir}" />
<classpath refid="test.classpath" />
<classpath refid="cobertura.classpath" />
<formatter type="xml" />
<test name="${testcase}" todir="${testreports.xml.dir}" if="testcase" />
<batchtest todir="${testreports.xml.dir}" unless="testcase">
<fileset dir="${testsrc.dir}" casesensitive="yes">
<include name="**/*Test.java" />
</fileset>
<fileset dir="${testsrc.common.dir}" casesensitive="yes">
<include name="**/*Test.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${testreports.html.dir}">
<fileset dir="${testreports.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${testreports.html.dir}" />
</junitreport>
</target>
<!-- override jar.main so we can jar up our mapred stuff too -->
<target name="jar" depends="subfloor-pkg.jar,jar-mapred,jar-hbase-comparators"/>
<!-- Jar the mapreduce libraries separately to reduce the payload when submitting
MapReduce jobs to hadoop -->
<target name="jar-mapred" depends="compile-mapred,generate.manifest">
<jar destfile="${dist.dir}/${mapred.artifact.name}" manifest="${dist.manifest.file}">
<fileset dir="${classes.common-mapred.dir}" />
</jar>
</target>
<target name="jar-hbase-comparators" depends="compile.compile">
<jar destfile="${dist.dir}/${hbase-comparators.artifact.name}" manifest="${dist.manifest.file}">
<fileset dir="${classes.dir}" includes="**/*Comparator*"/>
</jar>
</target>
<!-- Override assemble.copy-libs to put our jar in the root of the package -->
<target name="assemble.copy-libs">
<copy todir="${approot.stage.dir}/lib">
<fileset dir="${lib.dir}" />
<fileset file="${dist.dir}/${mapred.artifact.name}" />
</copy>
<copy todir="${approot.stage.dir}">
<fileset file="${dist.dir}/${ivy.artifact.id}-${project.revision}.jar" />
<fileset file="${dist.dir}/${hbase-comparators.artifact.name}" />
</copy>
</target>
<!-- override assemble to copy common package resources into the staging directory -->
<target name="assemble" depends="subfloor-pkg.assemble">
<!-- Copy common package resources over as well -->
<copy todir="${approot.stage.dir}" overwrite="true">
<fileset dir="${package.common.resdir}" />
</copy>
</target>
<!-- Publish the mapred jar as well -->
<target name="publish-local-nojar.post">
<antcall target="publish-local-nojar.internal">
<param name="ivy.artifact.id" value="${ivy.artifact.mapred.id}"/>
</antcall>
</target>
<!-- Build the mapred source jar that is required when publishing to a non-local repository -->
<target name="source.jar" depends="subfloor.source.jar">
<jar jarfile="${dist.dir}/${ivy.artifact.mapred.id}-${project.revision}-sources.jar" basedir="${src.common-mapred.dir}" />
</target>
<!-- Publish the mapred jar as well -->
<target name="publish-nojar" depends="subfloor.publish-nojar,subfloor-pkg.publish-nojar">
<antcall target="publish-nojar.internal">
<param name="ivy.artifact.id" value="${ivy.artifact.mapred.id}"/>
</antcall>
</target>
</project>