forked from apache/pig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
410 lines (360 loc) · 19.5 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
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You 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="Pig" default="jar">
<!-- 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" />
<!-- name and version properties -->
<property name="name" value="pig" />
<property name="Name" value="Pig" />
<property name="version" value="0.1.1-dev" />
<property name="final.name" value="${name}-${version}" />
<!-- source properties -->
<property name="lib.dir" value="${basedir}/lib/" />
<property name="src.dir" value="${basedir}/src/" />
<property name="src.lib.dir" value="${basedir}/lib-src/" />
<property name="src.gen.dir" value="${basedir}/src-gen/" />
<property name="src.docs.dir" value="${basedir}/docs/" />
<!-- javacc properties -->
<property name="src.gen.query.parser.dir" value="${src.gen.dir}/org/apache/pig/impl/logicalLayer/parser" />
<property name="src.gen.script.parser.dir" value="${src.gen.dir}/org/apache/pig/tools/pigscript/parser" />
<property name="src.gen.param.parser.dir" value="${src.gen.dir}/org/apache/pig/tools/parameters" />
<property name="javacc.home" value="${basedir}/lib" />
<!-- javac properties -->
<property name="javac.debug" value="on" />
<property name="javac.optimize" value="on" />
<property name="javac.deprecation" value="off" />
<property name="javac.version" value="1.5" />
<property name="javac.args" value="" />
<!-- TODO we should use warning... <property name="javac.args.warnings" value="-Xlint:unchecked" /> -->
<property name="javac.args.warnings" value="" />
<!-- build properties -->
<property name="build.dir" value="${basedir}/build" />
<property name="build.classes" value="${build.dir}/classes" />
<property name="build.docs" value="${build.dir}/docs" />
<property name="build.javadoc" value="${build.docs}/api" />
<property name="build.encoding" value="ISO-8859-1" />
<!-- TODO with only one version of hadoop in the lib folder we do not need that anymore -->
<property name="hadoop.jarfile" value="hadoop18.jar" />
<!-- distribution properties -->
<property name="staging.dir" value="${build.dir}/staging"/>
<property name="dist.dir" value="${staging.dir}/${final.name}"/>
<!-- jar names. TODO we might want to use the svn reversion name in the name in case it is a dev version -->
<property name="output.jarfile" value="${build.dir}/${final.name}.jar" />
<property name="output.jarfile.core" value="${build.dir}/${final.name}-core.jar" />
<property name="output.jarfile.sources" value="${build.dir}/${final.name}-sources.jar" />
<!-- Maintain old pig.jar in top level directory. -->
<property name="output.jarfile.backcompat" value="${basedir}/${name}.jar" />
<!-- test properties -->
<property name="test.src.dir" value="${basedir}/test" />
<property name="test.build.dir" value="${build.dir}/test" />
<property name="test.build.classes" value="${test.build.dir}/classes" />
<property name="test.log.dir" value="${test.build.dir}/logs" />
<property name="test.timeout" value="900000" />
<property name="test.junit.output.format" value="plain" />
<!-- test configuration, use ${user.home}/build.properties to configure values -->
<property name="ssh.gateway" value="" />
<property name="hod.server" value="" />
<property name="junit.hadoop.conf" value="" />
<property name="test.log.dir" value="${basedir}/test/logs"/>
<property name="junit.hadoop.conf" value="${user.home}/pigtest/conf/"/>
<property name="test.output" value="no"/>
<!-- javadoc properties -->
<property name="javadoc.link.java" value="http://java.sun.com/j2se/1.5.0/docs/api/" />
<!-- ====================================================== -->
<!-- Stuff needed by all targets -->
<!-- ====================================================== -->
<!-- setup the classpath -->
<path id="classpath">
<fileset file="${lib.dir}/${hadoop.jarfile}" />
<fileset file="${lib.dir}/javacc.jar" />
<fileset file="${lib.dir}/jsch-0.1.33.jar" />
<fileset file="${lib.dir}/junit-4.1.jar" />
</path>
<path id="test.classpath">
<pathelement location="${build.classes}"/>
<pathelement location="${test.src.dir}"/>
<path refid="classpath"/>
</path>
<target name="init">
<mkdir dir="${src.gen.query.parser.dir}" />
<mkdir dir="${src.gen.script.parser.dir}" />
<mkdir dir="${src.gen.param.parser.dir}" />
<mkdir dir="${staging.dir}" />
<mkdir dir="${dist.dir}" />
<mkdir dir="${build.classes}" />
<mkdir dir="${test.build.classes}" />
<tstamp>
<format property="timestamp" pattern="MMM dd yyyy, HH:mm:ss" />
</tstamp>
<svnversion outputproperty="svn.revision"/>
</target>
<macrodef name="svnversion">
<!-- the path needs to be small content otherwise it will take AGES ! -->
<attribute name="wcpath" default="${basedir}" />
<attribute name="outputproperty" />
<sequential>
<exec executable="svnversion" outputproperty="@{outputproperty}" failonerror="false" failifexecutionfails="false" >
<arg value="@{wcpath}" />
<redirector>
<outputfilterchain>
<tokenfilter>
<!-- version can be xxxx, xxxx:yyyy, xxxxM, xxxxS or xxxx:yyyyMS , ... just get the working copy one -->
<replaceregex pattern="((\d+).*)" replace="\2" />
</tokenfilter>
</outputfilterchain>
</redirector>
</exec>
</sequential>
</macrodef>
<!-- ================================================================== -->
<!-- Clean. Delete the build files, and their directories -->
<!-- ================================================================== -->
<target name="clean" description="Cleanup build artifacts">
<delete dir="${src.gen.dir}" />
<delete dir="${build.dir}" />
</target>
<!-- ================================================================== -->
<!-- Java Compiler Compiler, generate Parsers -->
<!-- ================================================================== -->
<target name="cc-compile" depends="init" description="Create and Compile Parser">
<jjtree target="${src.dir}/org/apache/pig/impl/logicalLayer/parser/QueryParser.jjt" outputdirectory="${src.gen.query.parser.dir}" javacchome="${javacc.home}" />
<javacc target="${src.gen.query.parser.dir}/QueryParser.jj" outputdirectory="${src.gen.query.parser.dir}" javacchome="${javacc.home}" />
<javacc target="${src.dir}/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj" outputdirectory="${src.gen.script.parser.dir}" javacchome="${javacc.home}" />
<javacc target="${src.dir}/org/apache/pig/tools/parameters/PigFileParser.jj" outputdirectory="${src.gen.param.parser.dir}" javacchome="${javacc.home}" />
<javacc target="${src.dir}/org/apache/pig/tools/parameters/ParamLoader.jj" outputdirectory="${src.gen.param.parser.dir}" javacchome="${javacc.home}" />
</target>
<!-- ================================================================== -->
<!-- Build sources -->
<!-- ================================================================== -->
<target name="compile" depends="init, cc-compile" description="Compile all artifacts">
<echo>*** Building Main Sources ***</echo>
<antcall target="compile-sources">
<param name="sources" value="${src.dir};${src.gen.dir};${src.lib.dir}/shock;${src.lib.dir}/bzip2" />
<param name="dist" value="${build.classes}" />
<param name="cp" value="classpath" />
</antcall>
</target>
<target name="compile-test" depends="compile">
<echo>*** Building Test Sources ***</echo>
<antcall target="compile-sources">
<param name="sources" value="${test.src.dir}" />
<param name="dist" value="${test.build.classes}" />
<param name="cp" value="test.classpath" />
</antcall>
</target>
<target name="compile-sources">
<javac encoding="${build.encoding}" srcdir="${sources}" includes="**/*.java" destdir="${dist}" debug="${javac.debug}" optimize="${javac.optimize}" target="${javac.version}" source="${javac.version}" deprecation="${javac.deprecation}">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="${cp}" />
</javac>
</target>
<!-- ================================================================== -->
<!-- Documentation -->
<!-- ================================================================== -->
<target name="javadoc" depends="jar" description="Create documentation">
<mkdir dir="${build.javadoc}" />
<javadoc overview="${src.docs.dir}/overview.html" packagenames="org.apache.pig.*" destdir="${build.javadoc}" author="true" version="true" use="true" windowtitle="${Name} ${version} API" doctitle="${Name} ${version} API" bottom="Copyright &copy; ${year} The Apache Software Foundation">
<packageset dir="${src.dir}" />
<link href="${javadoc.link.java}" />
<classpath>
<path refid="classpath" />
<pathelement path="${java.class.path}" />
<pathelement path="${output.jarfile}" />
</classpath>
<group title="pig" packages="org.apache.*" />
</javadoc>
</target>
<!-- ================================================================== -->
<!-- @depricated, Documentation -->
<!-- ================================================================== -->
<target name="doc" depends="javadoc">
</target>
<target name="source-jar" depends="cc-compile">
<jar duplicate="preserve" jarfile="${output.jarfile.sources}" basedir="${src.dir}">
<manifest>
<section name="org/apache/pig">
<attribute name="Implementation-Vendor" value="Apache" />
<attribute name="Implementation-Title" value="Pig" />
<attribute name="Implementation-Version" value="${version}" />
</section>
</manifest>
<fileset dir="${src.gen.dir}"/>
<fileset dir="${src.lib.dir}/shock"/>
<fileset dir="${src.lib.dir}/bzip2"/>
</jar>
</target>
<!-- ================================================================== -->
<!-- Make pig.jar -->
<!-- ================================================================== -->
<!-- TODO we should also exculte test here... -->
<!-- ================================================================== -->
<target name="jar" depends="compile" description="Create pig jar">
<antcall target="jarWithSvn"/>
<antcall target="jarWithOutSvn"/>
</target>
<target name="jarWithSvn" if="svn.revision">
<antcall target="buildJar">
<param name="svnString" value="${svn.revision}" />
</antcall>
</target>
<target name="jarWithOutSvn" unless="svn.revision">
<antcall target="buildJar">
<param name="svnString" value=": unknown" />
</antcall>
</target>
<target name="buildJar">
<echo>svnString ${svnString}</echo>
<jar jarfile="${output.jarfile.core}" basedir="${build.classes}">
<manifest>
<attribute name="Main-Class" value="org.apache.pig.Main" />
<section name="org/apache/pig">
<attribute name="Implementation-Vendor" value="Apache" />
<attribute name="Implementation-Title" value="Pig" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Build-TimeStamp" value="${timestamp}" />
<attribute name="Svn-Revision" value="${svnString}" />
</section>
</manifest>
<zipfileset src="${lib.dir}/junit-4.1.jar" />
<zipfileset src="${lib.dir}/${hadoop.jarfile}" />
<zipfileset src="${lib.dir}/jsch-0.1.33.jar" />
</jar>
<!-- @depricated -->
<jar jarfile="${output.jarfile}" basedir="${build.classes}">
<manifest>
<attribute name="Main-Class" value="org.apache.pig.Main" />
<section name="org/apache/pig">
<attribute name="Implementation-Vendor" value="Apache" />
<attribute name="Implementation-Title" value="Pig" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Build-TimeStamp" value="${timestamp}" />
<attribute name="Svn-Revision" value="${svnString}" />
</section>
</manifest>
<zipfileset src="${lib.dir}/junit-4.1.jar" />
<zipfileset src="${lib.dir}/${hadoop.jarfile}" />
<zipfileset src="${lib.dir}/jsch-0.1.33.jar" />
</jar>
<copy file="${output.jarfile}" tofile="${output.jarfile.backcompat}"/>
</target>
<!-- ================================================================== -->
<!-- Run unit tests -->
<!-- ================================================================== -->
<target name="test" depends="test-local,test-mapreduce" description="Run unit tests in local and mapreduce modes"/>
<target name="test-local" depends="compile-test,jar" description="Run unit tests in local mode">
<antcall target="testOneMode">
<param name="test.exectype" value="local" />
</antcall>
</target>
<target name="test-mapreduce" depends="compile-test,jar" description="Run unit tests in mapreduce mode">
<antcall target="testOneMode">
<param name="test.exectype" value="mapreduce" />
</antcall>
</target>
<target name="testOneMode">
<delete dir="${test.log.dir}-${test.exectype}"/>
<mkdir dir="${test.log.dir}-${test.exectype}"/>
<junit showoutput="${test.output}" printsummary="yes" haltonfailure="no" fork="yes" maxmemory="256m" dir="${basedir}" timeout="${test.timeout}" errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="test.exectype" value="${test.exectype}" />
<sysproperty key="ssh.gateway" value="${ssh.gateway}" />
<sysproperty key="hod.server" value="${hod.server}" />
<!-- <sysproperty key="hod.command" value="${hod.command}"/>
<sysproperty key="hod.param" value="${hod.param}"/> -->
<sysproperty key="hadoop.log.dir" value="${test.log.dir}-${test.exectype}"/>
<classpath>
<pathelement location="${output.jarfile}" />
<pathelement location="${test.build.classes}" />
<pathelement location="${junit.hadoop.conf}" />
<path refid="classpath"/>
</classpath>
<formatter type="${test.junit.output.format}" />
<batchtest fork="yes" todir="${test.log.dir}-${test.exectype}" unless="testcase">
<fileset dir="test">
<include name="**/*Test*.java" />
<exclude name="**/PigExecTestCase.java" />
<exclude name="**/TestLargeFile.java" />
<exclude name="**/TestOrderBy.java" />
<exclude name="**/TestPi.java" />
<exclude name="**/nightly/**" />
</fileset>
</batchtest>
<batchtest fork="yes" todir="${test.log.dir}-${test.exectype}" if="testcase">
<fileset dir="test" includes="**/${testcase}.java"/>
</batchtest>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</target>
<!-- ================================================================== -->
<!-- D I S T R I B U T I O N -->
<!-- ================================================================== -->
<target name="package" depends="jar, javadoc" description="Create a Pig release">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.dir}/lib" />
<mkdir dir="${dist.dir}/bin" />
<mkdir dir="${dist.dir}/docs" />
<mkdir dir="${dist.dir}/docs/api" />
<copy todir="${dist.dir}/lib" includeEmptyDirs="false">
<fileset dir="${lib.dir}">
</fileset>
</copy>
<copy file="${output.jarfile.core}" todir="${dist.dir}" />
<copy todir="${dist.dir}/bin">
<fileset dir="bin" />
</copy>
<copy todir="${dist.dir}/docs">
<fileset dir="${build.docs}" />
</copy>
<copy todir="${dist.dir}/test" includeEmptyDirs="true">
<fileset dir="${test.src.dir}" />
</copy>
<copy todir="${dist.dir}/src" includeEmptyDirs="true">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${dist.dir}/lib-src" includeEmptyDirs="true">
<fileset dir="${src.lib.dir}" />
</copy>
<copy todir="${dist.dir}/tutorial" includeEmptyDirs="true">
<fileset dir="tutorial" />
</copy>
<copy todir="${dist.dir}/contrib" includeEmptyDirs="true">
<fileset dir="contrib" />
</copy>
<copy todir="${dist.dir}/" file="build.xml" />
<copy todir="${dist.dir}">
<fileset dir=".">
<include name="*.txt" />
</fileset>
</copy>
<chmod perm="ugo+x" type="file">
<fileset dir="${dist.dir}/bin" />
</chmod>
</target>
<!-- ================================================================== -->
<!-- Make release tarball -->
<!-- ================================================================== -->
<target name="tar" depends="package" description="Create release tarball">
<tar compression="gzip" longfile="gnu" destfile="${build.dir}/${final.name}.tar.gz">
<tarfileset dir="${staging.dir}" mode="664">
<exclude name="${final.name}/bin/*" />
<include name="${final.name}/**" />
</tarfileset>
<tarfileset dir="${staging.dir}" mode="755">
<include name="${final.name}/bin/*" />
</tarfileset>
</tar>
</target>
</project>