a0e25191e9e2bbee6531ac34aa2ce9158ce7ebf6
[sqoop.git] / build.xml
1 <?xml version="1.0"?>
2
3 <!--
4 Copyright 2011 The Apache Software Foundation
5
6 Licensed to the Apache Software Foundation (ASF) under one
7 or more contributor license agreements. See the NOTICE file
8 distributed with this work for additional information
9 regarding copyright ownership. The ASF licenses this file
10 to you under the Apache License, Version 2.0 (the
11 "License"); you may not use this file except in compliance
12 with the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21 -->
22
23 <project name="sqoop" default="jar-all"
24 xmlns:artifact="urn:maven-artifact-ant"
25 xmlns:ivy="antlib:org.apache.ivy.ant">
26
27 <!-- load ant-contrib tasks to get the "if" task. -->
28 <taskdef resource="net/sf/antcontrib/antcontrib.properties">
29 <classpath>
30 <pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar"/>
31 </classpath>
32 </taskdef>
33
34 <!-- Load system-wide and project-wide default properties set by
35 the user, to avoid needing to override with -D. -->
36 <property file="${user.home}/build.properties" />
37 <property file="${basedir}/build.properties" />
38
39 <!-- some basic properties -->
40 <property environment="env"/>
41 <property name="name" value="sqoop" />
42 <property name="Name" value="Sqoop" />
43 <property name="version" value="1.5.0-SNAPSHOT" />
44
45 <!-- Ivy library properties -->
46 <property name="ivy.dir" location="${basedir}/ivy" />
47 <loadproperties srcfile="${ivy.dir}/libraries.properties"/>
48
49 <!-- The last version released. -->
50 <property name="oldversion" value="1.4.7" />
51 <!-- The point when we branched for the previous release. -->
52 <property name="prev.git.hash"
53 value="b0f391e75154be86f95378ab141f6dd1b3b59475" />
54
55 <property name="artifact.name" value="${name}-${version}" />
56 <property name="dest.jar" value="${artifact.name}.jar" />
57 <property name="test.jar" value="${name}-test-${version}.jar" />
58 <property name="git.hash" value="" />
59
60 <!-- programs used -->
61 <property name="python" value="python" />
62
63 <!-- locations in the source tree -->
64 <property name="base.src.dir" location="${basedir}/src" />
65 <property name="src.dir" location="${base.src.dir}/java" />
66 <property name="test.dir" location="${base.src.dir}/test" />
67 <property name="perftest.src.dir" location="${base.src.dir}/perftest" />
68 <property name="lib.dir" location="${basedir}/lib" />
69 <property name="docs.src.dir" location="${base.src.dir}/docs" />
70 <property name="script.src.dir" location="${base.src.dir}/scripts" />
71
72 <!-- base directory for all build/test process output -->
73 <property name="build.dir" location="${basedir}/build" />
74
75 <!-- generated bin scripts -->
76 <property name="build.bin.dir" location="${build.dir}/bin" />
77
78 <!-- generated source code -->
79 <property name="build.src.dir" location="${build.dir}/src" />
80
81 <!-- staging area for *-sources.jar files -->
82 <property name="build.srcjar.dir" location="${build.dir}/srcjars" />
83
84 <!-- compiled classes for the main sqoop artifact. -->
85 <property name="build.classes" location="${build.dir}/classes"/>
86
87 <!-- root directory for output/intermediate data for testing -->
88 <property name="build.test" location="${build.dir}/test"/>
89 <property name="test.log.dir" location="${build.dir}/test/logs"/>
90 <property name="test.build.extraconf" value="${build.test}/extraconf" />
91
92 <!-- compiled test classes -->
93 <property name="build.test.classes" location="${build.test}/classes" />
94
95 <!-- compiled "perftest" programs -->
96 <property name="build.perftest" location="${build.dir}/perftest"/>
97 <property name="build.perftest.classes" location="${build.perftest}/classes"/>
98
99 <!-- generated documentation output directory -->
100 <property name="build.javadoc" location="${build.dir}/docs/api" />
101
102 <!-- Target dir for release notes file. -->
103 <property name="build.relnotes.dir" location="${build.dir}/docs" />
104 <property name="relnotes.filename"
105 location="${build.relnotes.dir}/sqoop-${version}.releasenotes.html" />
106
107 <property name="bin.artifact.name" value="${artifact.name}.bin__hadoop-${hadoop.version}" />
108 <property name="dist.dir" location="${build.dir}/${bin.artifact.name}" />
109 <property name="tar.file" location="${build.dir}/${bin.artifact.name}.tar.gz" />
110 <property name="build.docs.timestamp"
111 location="${build.dir}/docs.timestamp" />
112
113 <property name="src.artifact.name" value="${artifact.name}" />
114 <property name="src.dist.dir" location="${build.dir}/${src.artifact.name}" />
115 <property name="src.tar.file" location="${build.dir}/${src.artifact.name}.tar.gz" />
116
117 <!-- compilation -->
118 <property name="targetJavaVersion" value="1.8" />
119 <property name="sourceJavaVersion" value="1.8" />
120 <property name="javac.deprecation" value="off"/>
121 <property name="javac.debug" value="on"/>
122 <property name="build.encoding" value="ISO-8859-1"/>
123
124 <!-- testing with JUnit -->
125 <property name="test.junit.output.format" value="plain"/>
126 <property name="test.output" value="no"/>
127 <property name="test.timeout" value="1200000"/>
128
129 <!-- static analysis -->
130 <property name="findbugs.out.dir" value="${build.dir}/findbugs" />
131 <property name="findbugs.output.xml.file"
132 value="${findbugs.out.dir}/report.xml" />
133 <property name="findbugs.output.html.file"
134 value="${findbugs.out.dir}/report.html" />
135
136 <!-- maven -->
137 <property name="mvn.build.dir" value="${build.dir}/m2" />
138 <property name="mvn.repo" value="snapshots" />
139 <property name="mvn.repo.id" value="cloudera.${mvn.repo}.repo" />
140 <property name="mvn.deploy.url"
141 value="https://repository.cloudera.com/content/repositories/${mvn.repo}"/>
142 <property name="sqoop.pom" value="${mvn.build.dir}/sqoop.pom" />
143 <property name="sqooptest.pom" value="${mvn.build.dir}/sqoop-test.pom" />
144
145 <!-- code coverage -->
146 <property name="cobertura.dir" value="${build.dir}/cobertura" />
147 <property name="cobertura.home" value="${cobertura.dir}" />
148 <property name="cobertura.report.dir" value="${cobertura.dir}/report" />
149 <property name="cobertura.format" value="html" /> <!-- may be 'xml' -->
150 <property name="cobertura.class.dir" value="${cobertura.dir}/classes" />
151
152 <!-- aspectJ fault injection -->
153 <import file="${test.dir}/aop/build/aop.xml"/>
154 <!-- Checking code style -->
155 <property name="checkstyle.xml" value="${test.dir}/checkstyle.xml" />
156 <property name="checkstyle.format.xsl"
157 value="${test.dir}/checkstyle-noframes.xsl" />
158 <property name="checkstyle.report.dir" value="${build.dir}" />
159
160 <!-- Release audit -->
161 <property name="rat.reporting.classname" value="rat.Report"/>
162
163 <!-- When testing with non-free JDBC drivers, override this parameter
164 to contain the path to the driver library dir.
165 -->
166 <property name="sqoop.thirdparty.lib.dir" value="" />
167
168 <!-- Ivy-based dependency resolution -->
169 <property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml"/>
170 <property name="ivy.jar" location="${lib.dir}/ivy-${ivy.version}.jar"/>
171 <property name="ivy_repo_url"
172 value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
173 <property name="mvn_repo_url"
174 value="http://repo2.maven.org/maven2/org/apache/maven/maven-ant-tasks/${mvn.version}/maven-ant-tasks-${mvn.version}.jar"/>
175 <property name="mvn.jar"
176 location="${build.dir}/maven-ant-tasks-${mvn.version}.jar" />
177 <property name="build.ivy.dir" location="${build.dir}/ivy" />
178 <property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib" />
179 <property name="build.ivy.report.dir" location="${build.ivy.dir}/report" />
180 <property name="redist.ivy.lib.dir"
181 location="${build.ivy.lib.dir}/${name}/redist"/>
182
183 <!--this is the naming policy for artifacts we want pulled down-->
184 <property name="ivy.artifact.retrieve.pattern"
185 value="${name}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
186
187 <!--test related properties -->
188 <property name="sqoop.test.oracle.connectstring" value="jdbc:oracle:thin:@//localhost/xe"/>
189 <property name="sqoop.test.oracle.username" value="SQOOPTEST"/>
190 <property name="sqoop.test.oracle.password" value="12345"/>
191
192 <property name="sqoop.test.mysql.connectstring.host_url"
193 value="jdbc:mysql://localhost/"/>
194
195 <property name="sqoop.test.mysql.username"
196 value="${env.USER}"/>
197 <property name="sqoop.test.mysql.password" value="" />
198 <property name="sqoop.test.mysql.databasename"
199 value="sqooptestdb"/>
200
201 <property name="sqoop.test.cubrid.connectstring.host_url"
202 value="jdbc:cubrid:localhost:30000"/>
203 <property name="sqoop.test.cubrid.connectstring.database" value="SQOOPCUBRIDTEST" />
204 <property name="sqoop.test.cubrid.connectstring.username" value="SQOOPUSER" />
205 <property name="sqoop.test.cubrid.connectstring.password" value="PASSWORD" />
206
207 <property name="sqoop.test.postgresql.connectstring.host_url"
208 value="jdbc:postgresql://localhost/"/>
209
210 <property name="sqoop.test.postgresql.database"
211 value="sqooptest" />
212
213 <property name="sqoop.test.postgresql.tablespace"
214 value="sqooptest" />
215
216 <property name="sqoop.test.postgresql.username"
217 value="sqooptest" />
218
219 <property name="sqoop.test.postgresql.password"
220 value="" />
221
222 <property name="sqoop.test.postgresql.pg_bulkload"
223 value="pg_bulkload" />
224
225 <property name="sqoop.test.sqlserver.connectstring.host_url"
226 value="jdbc:sqlserver://sqlserverhost:1433"/>
227
228 <property name="sqoop.test.sqlserver.database"
229 value="sqooptest"/>
230
231 <property name="ms.sqlserver.username"
232 value="SQOOPUSER"/>
233
234 <property name="ms.sqlserver.password"
235 value="PASSWORD"/>
236
237 <property name="sqoop.test.db2.connectstring.host_url" value="jdbc:db2://db2host:50000" />
238 <property name="sqoop.test.db2.connectstring.database" value="SQOOP" />
239 <property name="sqoop.test.db2.connectstring.username" value="SQOOP" />
240 <property name="sqoop.test.db2.connectstring.password" value="SQOOP" />
241
242 <property name="sqoop.test.netezza.host" value="nz-host" />
243 <property name="sqoop.test.netezza.port" value="5480" />
244 <property name="sqoop.test.netezza.username" value="ADMIN" />
245 <property name="sqoop.test.netezza.password" value="password" />
246 <property name="sqoop.test.netezza.db.name" value="SQOOP" />
247 <property name="sqoop.test.netezza.table.name" value="EMPNZ" />
248
249 <property name="sqoop.test.mainframe.ftp.host" value="localhost" />
250 <property name="sqoop.test.mainframe.ftp.port" value="2121" />
251 <property name="sqoop.test.mainframe.ftp.username" value="test" />
252 <property name="sqoop.test.mainframe.ftp.password" value="test" />
253 <property name="sqoop.test.mainframe.ftp.dataset.gdg" value="TSODIQ1.GDGTEXT" />
254 <property name="sqoop.test.mainframe.ftp.dataset.gdg.filename" value="G0001V43" />
255 <property name="sqoop.test.mainframe.ftp.dataset.gdg.md5" value="f0d0d171fdb8a03dbc1266ed179d7093" />
256 <property name="sqoop.test.mainframe.ftp.binary.dataset.gdg" value="TSODIQ1.FOLDER" />
257 <property name="sqoop.test.mainframe.ftp.binary.dataset.gdg.filename" value="G0002V45" />
258 <property name="sqoop.test.mainframe.ftp.binary.dataset.gdg.md5" value="43eefbe34e466dd3f65a3e867a60809a" />
259 <property name="sqoop.test.mainframe.ftp.dataset.seq" value="TSODIQ1.GDGTEXT.G0001V43" />
260 <property name="sqoop.test.mainframe.ftp.dataset.seq.filename" value="G0001V43" />
261 <property name="sqoop.test.mainframe.ftp.dataset.seq.md5" value="f0d0d171fdb8a03dbc1266ed179d7093" />
262 <property name="sqoop.test.mainframe.ftp.binary.dataset.seq" value="TSODIQ1.FOLDER.FOLDERTXT" />
263 <property name="sqoop.test.mainframe.ftp.binary.dataset.seq.filename" value="FOLDERTXT" />
264 <property name="sqoop.test.mainframe.ftp.binary.dataset.seq.md5" value="1591c0fcc718fda7e9c1f3561d232b2b" />
265 <property name="sqoop.test.mainframe.ftp.binary.dataset.mixed" value="TSODIQ1.MIXED" />
266 <property name="sqoop.test.mainframe.ftp.binary.dataset.mixed.filename" value="G0039V00" />
267 <property name="sqoop.test.mainframe.ftp.binary.dataset.mixed.md5" value="5e7f4ec7cbeae8e0e0b4d88346eb9349" />
268 <property name="s3.bucket.url" value="" />
269 <property name="s3.generator.command" value="" />
270
271 <condition property="windows">
272 <os family="windows" />
273 </condition>
274
275 <condition property="skip-real-docs">
276 <or>
277 <isset property="docs.uptodate" />
278 <os family="windows" />
279 </or>
280 </condition>
281
282 <if>
283 <isset property="sqoop.test.msserver.connector.factory"/>
284 <then>
285 <echo message="Use ${sqoop.test.msserver.connector.factory}"/>
286 </then>
287 <else>
288 <echo message="Use built-in SQL server connector by default"/>
289 <property name="sqoop.test.msserver.connector.factory"
290 value="org.apache.sqoop.manager.DefaultManagerFactory"/>
291 </else>
292 </if>
293
294 <!-- The classpath for compiling and running Sqoop -->
295 <if>
296 <isset property="hadoop.home" />
297 <then>
298 <path id="compile.classpath">
299 <pathelement location="${build.classes}"/>
300 <path refid="lib.path"/>
301 <fileset dir="${hadoop.home}">
302 <include name="hadoop-core-*.jar" />
303 <include name="hadoop-*-core.jar" />
304 <include name="hadoop-common-*.jar" />
305 <include name="hadoop-mapred-*.jar" />
306 <include name="hadoop-hdfs-*.jar" />
307 </fileset>
308 <fileset dir="${hadoop.home}/lib">
309 <include name="*.jar" />
310 </fileset>
311 <path refid="${name}.hadoop.classpath"/>
312 </path>
313 </then>
314 <else>
315 <path id="compile.classpath">
316 <pathelement location="${build.classes}"/>
317 <path refid="lib.path"/>
318 <path refid="${name}.hadoop.classpath"/>
319 </path>
320 </else>
321 </if>
322
323 <path id="cobertura.classpath">
324 <fileset dir="${cobertura.home}">
325 <include name="**/*.jar" />
326 </fileset>
327 </path>
328
329 <!-- "init" target used for setup purposes. -->
330 <target name="init">
331 <!-- Path containing third-party libraries deployed directly with Sqoop.
332 This does not include anything that Ivy can retrieve for us.
333 -->
334 <path id="lib.path">
335 <fileset dir="${lib.dir}">
336 <include name="*.jar" />
337 </fileset>
338 </path>
339
340 <!-- Classpath for unit tests (superset of compile.classpath) -->
341 <path id="test.classpath">
342 <pathelement location="${build.test.classes}" />
343 <pathelement location="${test.build.extraconf}"/>
344 <path refid="${name}.hadooptest.classpath" />
345 <path refid="compile.classpath" />
346 </path>
347 </target>
348
349 <!-- generate the version information class. -->
350 <target name="gen-version" depends="init">
351 <if>
352 <equals arg1="${windows}" arg2="true" />
353 <then>
354 <exec executable="${script.src.dir}/write-version-info.cmd"
355 dir="${basedir}" failonerror="true">
356 <arg value="${build.dir}" />
357 <arg value="${version}" />
358 <arg value="${git.hash}" />
359 </exec>
360 </then>
361 <else>
362 <exec executable="${script.src.dir}/write-version-info.sh"
363 dir="${basedir}" failonerror="true">
364 <arg value="${build.dir}" />
365 <arg value="${version}" />
366 <arg value="${git.hash}" />
367 </exec>
368 </else>
369 </if>
370 </target>
371
372 <!-- Compile core classes for the project -->
373 <target name="compile"
374 depends="init, gen-version, ivy-retrieve-hadoop"
375 description="Compile core classes for the project">
376 <!-- don't use an out-of-date instrumented build. -->
377 <delete dir="${cobertura.class.dir}" />
378 <!-- ensure normal build target dir exists -->
379 <mkdir dir="${build.classes}" />
380
381 <!-- Compile generated code first. -->
382 <javac
383 encoding="${build.encoding}"
384 srcdir="${build.src.dir}"
385 includes="**/*.java"
386 destdir="${build.classes}"
387 debug="${javac.debug}"
388 source="${sourceJavaVersion}"
389 target="${targetJavaVersion}"
390 deprecation="${javac.deprecation}">
391 <classpath refid="compile.classpath"/>
392 </javac>
393
394 <!-- Compile the main code. -->
395 <javac
396 encoding="${build.encoding}"
397 srcdir="${src.dir}"
398 includes="**/*.java"
399 destdir="${build.classes}"
400 debug="${javac.debug}"
401 source="${sourceJavaVersion}"
402 target="${targetJavaVersion}"
403 deprecation="${javac.deprecation}">
404 <classpath refid="compile.classpath"/>
405 </javac>
406 </target>
407
408 <target name="compile-test"
409 depends="compile, ivy-retrieve-hadoop-test"
410 description="Compile test classes">
411 <mkdir dir="${build.test.classes}" />
412 <mkdir dir="${test.build.extraconf}"/>
413 <javac
414 encoding="${build.encoding}"
415 srcdir="${test.dir}"
416 includes="**/*.java"
417 destdir="${build.test.classes}"
418 source="${sourceJavaVersion}"
419 target="${targetJavaVersion}"
420 debug="${javac.debug}">
421 <classpath>
422 <path refid="test.classpath"/>
423 </classpath>
424 </javac>
425 </target>
426
427 <target name="compile-perf-test"
428 depends="compile, ivy-retrieve-hadoop-test"
429 description="Compile manual performance tests">
430 <mkdir dir="${build.perftest.classes}" />
431 <javac
432 encoding="${build.encoding}"
433 srcdir="${perftest.src.dir}"
434 includes="**/*.java"
435 destdir="${build.perftest.classes}"
436 source="${sourceJavaVersion}"
437 target="${targetJavaVersion}"
438 debug="${javac.debug}">
439 <classpath>
440 <path refid="test.classpath"/>
441 </classpath>
442 </javac>
443 </target>
444
445 <target name="jar" depends="compile" description="Create main jar">
446 <jar jarfile="${build.dir}/${dest.jar}" basedir="${build.classes}" />
447 </target>
448
449 <target name="jar-test" depends="compile-test" description="Create test jar">
450 <jar jarfile="${build.dir}/${test.jar}" basedir="${build.test.classes}" />
451 </target>
452
453 <!-- Ensure that all source code can be built -->
454 <target name="compile-all"
455 depends="compile,compile-test,compile-perf-test"
456 description="Compile all sources"/>
457
458 <!-- Create all jars. Note this does not include the perftests. -->
459 <target name="jar-all" depends="jar,jar-test"
460 description="Create all jar artifacts" />
461
462 <target name="scripts" depends="jar"
463 description="Create tool-specific wrapper scripts">
464 <!-- Take the list of available tools from 'sqoop help' and generate
465 the wrapper scripts to invoke each of these.
466 -->
467 <mkdir dir="${build.bin.dir}" />
468 <if>
469 <equals arg1="${windows}" arg2="true" />
470 <then>
471 <java classname="org.apache.sqoop.Sqoop"
472 fork="true"
473 failonerror="true"
474 output="${build.dir}/tools-list"
475 error="NUL">
476 <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />
477 <arg value="help" />
478 <classpath refid="compile.classpath"/>
479 </java>
480 <exec executable="${script.src.dir}/create-tool-scripts.cmd"
481 dir="${basedir}" failonerror="true">
482 <arg value="${build.bin.dir}" />
483 <arg value="${script.src.dir}/tool-script.cmd.template" />
484 <arg value="${build.dir}/tools-list" />
485 </exec>
486 </then>
487 <else>
488 <java classname="org.apache.sqoop.Sqoop"
489 fork="true"
490 failonerror="true"
491 output="${build.dir}/tools-list"
492 error="/dev/null">
493 <jvmarg value="-Dhadoop.security.log.file=./build/security-audit.log" />
494 <arg value="help" />
495 <classpath refid="compile.classpath"/>
496 </java>
497 <exec executable="${script.src.dir}/create-tool-scripts.sh"
498 dir="${basedir}" failonerror="true">
499 <arg value="${build.bin.dir}" />
500 <arg value="${script.src.dir}/tool-script.sh.template" />
501 <arg value="${build.dir}/tools-list" />
502 </exec>
503 </else>
504 </if>
505 </target>
506
507 <target name="package"
508 depends="jar-all,compile-all,docs,ivy-retrieve-redist,scripts"
509 description="Create a redistributable package">
510
511 <mkdir dir="${dist.dir}"/>
512
513 <!-- copy in the build artifact -->
514 <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
515 <fileset dir="${build.dir}">
516 <include name="${dest.jar}" />
517 </fileset>
518 </copy>
519
520 <!-- copy the test artifact -->
521 <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="true">
522 <fileset dir="${build.dir}">
523 <include name="${test.jar}" />
524 </fileset>
525 </copy>
526
527 <!-- copy in various components of the initial source layout
528 so that the redistributable can bootstrap itself. -->
529 <copy todir="${dist.dir}" includeEmptyDirs="false" flatten="false">
530 <fileset dir="${basedir}" defaultexcludes="no">
531 <include name="**/*" />
532 <exclude name="build/**" />
533 <exclude name="lib/**" />
534 <exclude name=".git/**" />
535 <exclude name="tags" />
536 <exclude name=".project" />
537 <exclude name=".classpath" />
538 <exclude name="conf/managers.d/**" />
539 <exclude name="conf/tools.d/**" />
540 </fileset>
541 </copy>
542
543 <!-- copy the dependency libraries from ivy into the output lib dir -->
544 <mkdir dir="${dist.dir}/lib"/>
545 <copy todir="${dist.dir}/lib" includeEmptyDirs="false" flatten="true">
546 <fileset dir="${redist.ivy.lib.dir}">
547 <include name="**/*.jar" />
548 </fileset>
549 </copy>
550
551 <copy todir="${dist.dir}/lib" includeEmptyDirs="false">
552 <fileset dir="${lib.dir}">
553 <include name="**/*" />
554 <exclude name="ivy*" />
555 </fileset>
556 </copy>
557
558 <!-- copy in documentation build artifacts -->
559 <copy todir="${dist.dir}/docs" includeEmptyDirs="false" flatten="false">
560 <fileset dir="${build.dir}/docs">
561 <include name="**/*.html" />
562 <include name="**/*.css" />
563 <include name="images/**" />
564 </fileset>
565 </copy>
566 <copy todir="${dist.dir}/docs/man" includeEmptyDirs="false" flatten="false">
567 <fileset dir="${build.dir}/docs">
568 <include name="**/*.gz" />
569 </fileset>
570 </copy>
571
572 <!-- copy in auto-generated bin scripts -->
573 <copy todir="${dist.dir}/bin" includeEmptyDirs="false" flatten="true">
574 <fileset dir="${build.bin.dir}">
575 <include name="*" />
576 </fileset>
577 </copy>
578
579 <!-- make sure the bin scripts are executable. -->
580 <chmod perm="ugo+x" type="file" parallel="false">
581 <fileset dir="${dist.dir}/bin" />
582 <fileset dir="${dist.dir}/testdata/hive/bin" />
583 </chmod>
584
585 <!-- make sure any scripts named *.sh are executable. -->
586 <chmod perm="ugo+x" type="file" parallel="false">
587 <fileset dir="${dist.dir}">
588 <include name="**/*.sh" />
589 </fileset>
590 </chmod>
591
592 <!-- In the configuration directory, take the sqoop-site-template
593 and copy it to sqoop-site.xml, overwriting any user-specified
594 sqoop-site.xml in there.
595 -->
596 <copy file="${dist.dir}/conf/sqoop-site-template.xml"
597 tofile="${dist.dir}/conf/sqoop-site.xml"
598 overwrite="true" />
599 </target>
600
601 <target name="tar" depends="package" description="Create release tarball">
602 <tar compression="gzip" longfile="gnu" destfile="${tar.file}">
603 <tarfileset dir="${build.dir}" mode="664">
604 <exclude name="${bin.artifact.name}/bin/*" />
605 <exclude name="${bin.artifact.name}/testdata/hive/bin/*" />
606 <exclude name="${bin.artifact.name}/**/*.sh" />
607 <include name="${bin.artifact.name}/**" />
608 </tarfileset>
609 <tarfileset dir="${build.dir}" mode="755">
610 <include name="${bin.artifact.name}/bin/*" />
611 <include name="${bin.artifact.name}/testdata/hive/bin/*" />
612 <include name="${bin.artifact.name}/testdata/hcatalog/conf/*" />
613 <include name="${bin.artifact.name}/**/*.sh" />
614 </tarfileset>
615 </tar>
616 </target>
617
618 <target name="srcpackage" description="Create a redistributable source package">
619
620 <mkdir dir="${src.dist.dir}"/>
621
622 <!-- copy in various components of the initial source layout
623 so that the redistributable can bootstrap itself. -->
624 <copy todir="${src.dist.dir}" includeEmptyDirs="false" flatten="false">
625 <fileset dir="${basedir}" defaultexcludes="no">
626 <include name="**/*" />
627 <exclude name="build/**" />
628 <exclude name=".git/**" />
629 <exclude name="tags" />
630 <exclude name=".project" />
631 <exclude name=".classpath" />
632 <exclude name="conf/managers.d/**" />
633 <exclude name="conf/tools.d/**" />
634 </fileset>
635 </copy>
636
637 <!-- make sure the bin scripts are executable. -->
638 <chmod perm="ugo+x" type="file" parallel="false">
639 <fileset dir="${src.dist.dir}/bin" />
640 <fileset dir="${src.dist.dir}/testdata/hive/bin" />
641 </chmod>
642
643 <!-- make sure any scripts named *.sh are executable. -->
644 <chmod perm="ugo+x" type="file" parallel="false">
645 <fileset dir="${src.dist.dir}">
646 <include name="**/*.sh" />
647 </fileset>
648 </chmod>
649 </target>
650
651 <target name="srctar" depends="srcpackage" description="Create release source tarball">
652 <tar compression="gzip" longfile="gnu" destfile="${src.tar.file}">
653 <tarfileset dir="${build.dir}" mode="664">
654 <exclude name="${src.artifact.name}/bin/*" />
655 <exclude name="${src.artifact.name}/testdata/hive/bin/*" />
656 <exclude name="${src.artifact.name}/testdata/hcatalog/conf/*" />
657 <exclude name="${src.artifact.name}/**/*.sh" />
658 <include name="${src.artifact.name}/**" />
659 </tarfileset>
660 <tarfileset dir="${build.dir}" mode="755">
661 <include name="${src.artifact.name}/bin/*" />
662 <include name="${src.artifact.name}/testdata/hive/bin/*" />
663 <include name="${src.artifact.name}/testdata/hcatalog/conf/*" />
664 <include name="${src.artifact.name}/**/*.sh" />
665 </tarfileset>
666 </tar>
667 </target>
668
669 <!-- set variables that configure the actual test -->
670 <target name="test-prep" depends="test-prep-normal,test-prep-thirdparty,
671 test-prep-manual"/>
672
673 <path id="hcatalog.conf.dir">
674 <pathelement location="${basedir}/testdata/hcatalog/conf"/>
675 </path>
676 <target name="test-eval-condition">
677 <condition property="thirdparty_or_manual">
678 <or>
679 <isset property="thirdparty"/>
680 <isset property="manual"/>
681 </or>
682 </condition>
683 </target>
684
685
686
687 <target name="test-prep-normal" unless="thirdparty_or_manual"
688 depends="test-eval-condition">
689 <!-- Set this to run all the "standard" tests -->
690 <property name="test.pattern" value="Test*" />
691 <property name="cobertura.testset" value="base" />
692 </target>
693
694 <target name="test-prep-thirdparty" if="thirdparty">
695 <!-- Run tests that *end* with the name Test, instead of starting with it;
696 this runs non-standard tests e.g. third-party database tests. -->
697 <property name="test.pattern" value="*Test" />
698 <property name="test.exclude" value="*ManualTest" />
699 <property name="cobertura.testset" value="thirdparty" />
700 </target>
701
702 <target name="test-prep-manual" if="manual">
703 <!-- Run tests that are marked for manualtest execution -->
704 <property name="test.pattern" value="*ManualTest" />
705 <property name="cobertura.testset" value="manual" />
706 </target>
707
708 <!-- ================================================================== -->
709 <!-- Run unit tests -->
710 <!-- By default, we'll run the "normal" tests: Test*.java -->
711 <!-- To run third-party tests, run with -Dthirdparty=true -->
712 <!-- ================================================================== -->
713 <target name="test"
714 depends="compile-test,compile,test-prep,run-tests"
715 description="Run unit tests" />
716
717 <!-- actually run the selected unit tests -->
718 <target name="run-tests"
719 depends="compile-test,compile,test-prep">
720 <antcall target="checkfailure" inheritRefs="true" />
721 </target>
722
723 <property name="remoteDebug" value="false"/>
724
725 <target name="test-core">
726 <!-- inner target only intended to be used via antcall.
727 Does not define its dependencies. Should be invoked through the
728 'test' target. Does not fail the build if tests fail.
729 -->
730 <!-- use ant test -DremoteDebug=true to enable remote debugging -->
731 <condition property="remoteDebugJvmArgs"
732 value="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=2601"
733 else="-ea">
734 <istrue value="${remoteDebug}"/>
735 </condition>
736 <delete dir="${test.log.dir}"/>
737 <mkdir dir="${test.log.dir}"/>
738 <delete dir="${build.test}/data"/>
739 <mkdir dir="${build.test}/data/sqoop" />
740 <mkdir dir="${cobertura.class.dir}" />
741 <copy file="${test.dir}/fi-site.xml"
742 todir="${test.build.extraconf}" />
743 <copy file="${basedir}/conf/oraoop-site-template.xml"
744 todir="${test.build.extraconf}" />
745 <copy todir="${test.build.extraconf}/oraoop">
746 <fileset dir="${test.dir}/oraoop"/>
747 </copy>
748 <copy file="${basedir}/conf/password-file.txt"
749 todir="${test.build.extraconf}" />
750 <copy file="${basedir}/conf/wrong-password-file.txt"
751 todir="${test.build.extraconf}" />
752 <junit
753 printsummary="yes" showoutput="${test.output}"
754 haltonfailure="no" fork="yes" maxmemory="5120m"
755 errorProperty="tests.failed" failureProperty="tests.failed"
756 timeout="${test.timeout}"
757 dir="${build.test}/data">
758
759 <!-- enable asserts in tests -->
760 <jvmarg value="-ea" />
761
762 <!-- We need to disable asserts in HadoopThriftAuthBridge to be able to run HiveMiniCluster tests. -->
763 <jvmarg value="-da:org.apache.hadoop.hive.thrift.HadoopThriftAuthBridge" />
764
765 <jvmarg value="${remoteDebugJvmArgs}"/>
766
767 <sysproperty key="test.build.data" value="${build.test}/data"/>
768 <sysproperty key="build.test" value="${build.test}"/>
769
770 <!-- microsoft sqlserver thirdparty test related properties-->
771 <sysproperty key="test.data.dir" value="${basedir}/testdata"/>
772 <sysproperty key="ms.datatype.test.data.file.export" value="DatatypeTestData-export-lite.txt"/>
773 <sysproperty key="ms.datatype.test.data.file.import" value="DatatypeTestData-import-lite.txt"/>
774 <sysproperty key="ms.datatype.test.data.file.delim" value=","/>
775 <sysproperty key="ms.datatype.test.hdfsprefix" value="file:///"/>
776 <sysproperty key="ms.sqlserver.username" value="${ms.sqlserver.username}"/>
777 <sysproperty key="ms.sqlserver.password" value="${ms.sqlserver.password}"/>
778
779 <sysproperty key="net.sourceforge.cobertura.datafile"
780 value="${cobertura.dir}/cobertura-${cobertura.testset}.ser" />
781
782 <!-- define this property to force Sqoop to throw better exceptions on
783 errors during testing, instead of printing a short message and
784 exiting with status 1.
785 -->
786 <sysproperty key="sqoop.throwOnError" value="" />
787
788 <!-- we want more log4j output when running unit tests -->
789 <sysproperty key="hadoop.root.logger"
790 value="DEBUG,console" />
791
792 <!-- requires fork=yes for:
793 relative File paths to use the specified user.dir
794 classpath to use build/*.jar
795 -->
796 <sysproperty key="user.dir" value="${build.test}/data"/>
797
798 <!-- Setting the user.dir property is actually meaningless as it
799 is read-only in the Linux Sun JDK. Provide an alternate sysprop
800 to specify where generated code should go.
801 -->
802 <sysproperty key="sqoop.src.dir" value="${build.test}/data"/>
803
804 <!-- Override standalone Hadoop's working dirs to allow parallel
805 execution of multiple Hudson builders
806 -->
807 <sysproperty key="hadoop.tmp.dir" value="${build.test}/hadoop"/>
808
809 <!--
810 Set to an empty string below due to MAPREDUCE-3736
811 <sysproperty key="fs.default.name" value="${fs.default.name}"/>
812 -->
813 <sysproperty key="fs.default.name" value=""/>
814 <sysproperty key="hadoop.test.localoutputfile"
815 value="${hadoop.test.localoutputfile}"/>
816 <sysproperty key="hadoop.log.dir" value="${test.log.dir}"/>
817
818 <!-- we have a mock "hive" shell instance in our testdata directory
819 for testing hive integration. Set this property here to ensure
820 that the unit tests pick it up.
821 -->
822 <sysproperty key="hive.home" value="${basedir}/testdata/hive" />
823
824 <!-- By default the Oracle tests assume an Oracle XE installation
825 with a hardcoded connection string. If you want to overwrite
826 that specify the value at command line or via
827 build.properties file.
828 -->
829 <sysproperty key="sqoop.test.oracle.connectstring"
830 value="${sqoop.test.oracle.connectstring}"/>
831
832 <sysproperty key="sqoop.test.oracle.username"
833 value="${sqoop.test.oracle.username}"/>
834
835 <sysproperty key="sqoop.test.oracle.password"
836 value="${sqoop.test.oracle.password}"/>
837
838 <sysproperty key="sqoop.test.mysql.connectstring.host_url"
839 value="${sqoop.test.mysql.connectstring.host_url}"/>
840
841 <sysproperty key="sqoop.test.mysql.username"
842 value="${sqoop.test.mysql.username}"/>
843
844 <sysproperty key="sqoop.test.mysql.password"
845 value="${sqoop.test.mysql.password}"/>
846
847 <sysproperty key="sqoop.test.mysql.databasename"
848 value="${sqoop.test.mysql.databasename}"/>
849
850 <sysproperty key="sqoop.test.cubrid.connectstring.host_url"
851 value="${sqoop.test.cubrid.connectstring.host_url}"/>
852
853 <sysproperty key="sqoop.test.cubrid.connectstring.database"
854 value="${sqoop.test.cubrid.connectstring.database}"/>
855
856 <sysproperty key="sqoop.test.cubrid.connectstring.username"
857 value="${sqoop.test.cubrid.connectstring.username}"/>
858
859 <sysproperty key="sqoop.test.cubrid.connectstring.password"
860 value="${sqoop.test.cubrid.connectstring.password}"/>
861
862 <sysproperty key="sqoop.test.postgresql.connectstring.host_url"
863 value="${sqoop.test.postgresql.connectstring.host_url}"/>
864
865 <sysproperty key="sqoop.test.postgresql.database"
866 value="${sqoop.test.postgresql.database}" />
867
868 <sysproperty key="sqoop.test.postgresql.tablespace"
869 value="${sqoop.test.postgresql.tablespace}" />
870
871 <sysproperty key="sqoop.test.postgresql.username"
872 value="${sqoop.test.postgresql.username}" />
873
874 <sysproperty key="sqoop.test.postgresql.password"
875 value="${sqoop.test.postgresql.password}" />
876
877 <sysproperty key="sqoop.test.postgresql.pg_bulkload"
878 value="${sqoop.test.postgresql.pg_bulkload}" />
879
880 <sysproperty key="sqoop.test.sqlserver.connectstring.host_url"
881 value="${sqoop.test.sqlserver.connectstring.host_url}"/>
882
883 <sysproperty key="sqoop.test.sqlserver.database"
884 value="${sqoop.test.sqlserver.database}"/>
885
886 <sysproperty key="sqoop.test.msserver.connector.factory"
887 value="${sqoop.test.msserver.connector.factory}"/>
888
889 <sysproperty key="sqoop.test.db2.connectstring.host_url" value="${sqoop.test.db2.connectstring.host_url}" />
890 <sysproperty key="sqoop.test.db2.connectstring.database" value="${sqoop.test.db2.connectstring.database}" />
891 <sysproperty key="sqoop.test.db2.connectstring.username" value="${sqoop.test.db2.connectstring.username}" />
892 <sysproperty key="sqoop.test.db2.connectstring.password" value="${sqoop.test.db2.connectstring.password}" />
893
894 <sysproperty key="sqoop.test.netezza.host" value="${sqoop.test.netezza.host}" />
895 <sysproperty key="sqoop.test.netezza.port" value="${sqoop.test.netezza.port}" />
896 <sysproperty key="sqoop.test.netezza.username" value="${sqoop.test.netezza.username}" />
897 <sysproperty key="sqoop.test.netezza.password" value="${sqoop.test.netezza.password}" />
898 <sysproperty key="sqoop.test.netezza.db.name" value="${sqoop.test.netezza.db.name}" />
899 <sysproperty key="sqoop.test.netezza.table.name" value="${sqoop.test.netezza.table.name}" />
900
901 <sysproperty key="sqoop.test.mainframe.ftp.host" value="${sqoop.test.mainframe.ftp.host}" />
902 <sysproperty key="sqoop.test.mainframe.ftp.port" value="${sqoop.test.mainframe.ftp.port}" />
903 <sysproperty key="sqoop.test.mainframe.ftp.username" value="${sqoop.test.mainframe.ftp.username}" />
904 <sysproperty key="sqoop.test.mainframe.ftp.password" value="${sqoop.test.mainframe.ftp.password}" />
905 <sysproperty key="sqoop.test.mainframe.ftp.dataset.gdg" value="${sqoop.test.mainframe.ftp.dataset.gdg}" />
906 <sysproperty key="sqoop.test.mainframe.ftp.dataset.gdg.filename" value="${sqoop.test.mainframe.ftp.dataset.gdg.filename}" />
907 <sysproperty key="sqoop.test.mainframe.ftp.dataset.gdg.md5" value="${sqoop.test.mainframe.ftp.dataset.gdg.md5}" />
908 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.gdg" value="${sqoop.test.mainframe.ftp.binary.dataset.gdg}" />
909 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.gdg.filename" value="${sqoop.test.mainframe.ftp.binary.dataset.gdg.filename}" />
910 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.gdg.md5" value="${sqoop.test.mainframe.ftp.binary.dataset.gdg.md5}" />
911
912 <sysproperty key="s3.bucket.url" value="${s3.bucket.url}" />
913 <sysproperty key="s3.generator.command" value="${s3.generator.command}" />
914
915 <sysproperty key="sqoop.test.mainframe.ftp.dataset.seq" value="${sqoop.test.mainframe.ftp.dataset.seq}" />
916 <sysproperty key="sqoop.test.mainframe.ftp.dataset.seq.filename" value="${sqoop.test.mainframe.ftp.dataset.seq.filename}" />
917 <sysproperty key="sqoop.test.mainframe.ftp.dataset.seq.md5" value="${sqoop.test.mainframe.ftp.dataset.seq.md5}" />
918 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.seq" value="${sqoop.test.mainframe.ftp.binary.dataset.seq}" />
919 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.seq.filename" value="${sqoop.test.mainframe.ftp.binary.dataset.seq.filename}" />
920 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.seq.md5" value="${sqoop.test.mainframe.ftp.binary.dataset.seq.md5}" />
921 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.mixed" value="${sqoop.test.mainframe.ftp.binary.dataset.mixed}" />
922 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.mixed.filename" value="${sqoop.test.mainframe.ftp.binary.dataset.mixed.filename}" />
923 <sysproperty key="sqoop.test.mainframe.ftp.binary.dataset.mixed.md5" value="${sqoop.test.mainframe.ftp.binary.dataset.mixed.md5}" />
924 <!-- Location of Hive logs -->
925 <!--<sysproperty key="hive.log.dir"
926 value="${test.build.data}/sqoop/logs"/> -->
927
928 <classpath>
929 <!-- instrumented classes go ahead of normal classes -->
930 <pathelement location="${cobertura.class.dir}" />
931
932 <!-- Location of hive-site xml and other hadoop config files -->
933 <path refid="hcatalog.conf.dir" />
934
935 <!-- main classpath here. -->
936 <path refid="test.classpath" />
937
938 <!-- need thirdparty JDBC drivers for thirdparty tests -->
939 <fileset dir="${sqoop.thirdparty.lib.dir}"
940 includes="*.jar" />
941
942 <!-- include cobertura itself on the classpath -->
943 <path refid="cobertura.classpath" />
944 </classpath>
945 <formatter type="${test.junit.output.format}" />
946 <batchtest todir="${build.test}" unless="testcase">
947 <fileset dir="${test.dir}"
948 includes="**/${test.pattern}.java"
949 excludes="**/${test.exclude}.java,**/KerberizedTest.java,**/IntegrationTest.java,**/SqoopTest.java,
950 **/UnitTest.java,**/CubridTest.java,**/Db2Test.java,**/MainFrameTest.java,**/MysqlTest.java,
951 **/NetezzaTest.java,**/OracleTest.java,**/PostgresqlTest.java,**/S3Test.java,**/SqlServerTest.java,
952 **/ThirdPartyTest.java"/>
953 </batchtest>
954 <batchtest todir="${build.test}" if="testcase">
955 <fileset dir="${test.dir}" includes="**/${testcase}.java"/>
956 </batchtest>
957 </junit>
958 </target>
959
960 <target name="releaseaudit" depends="package,ivy-retrieve-releaseaudit"
961 description="Audit license headers for release">
962 <fail unless="rat.present"
963 message="Failed to load class [${rat.reporting.classname}]." />
964 <java classname="${rat.reporting.classname}" fork="true"
965 output="${build.dir}/rat.log">
966 <classpath refid="${name}.releaseaudit.classpath" />
967 <arg value="${dist.dir}" />
968 </java>
969 <exec executable="${script.src.dir}/rat-violations.sh" failOnError="true">
970 <arg value="${build.dir}/rat.log" />
971 <arg value="${dist.dir}" />
972 </exec>
973 <echo message="Release audit appears okay. Full results are in " />
974 <echo message="${build.dir}/rat.log" />
975 </target>
976
977 <target name="docs-uptodate" depends="init">
978 <uptodate property="docs.uptodate">
979 <srcfiles dir="${basedir}/src/docs/">
980 <include name="**/*.txt" />
981 </srcfiles>
982 <mapper type="merge" to="${build.docs.timestamp}" />
983 </uptodate>
984 </target>
985
986 <target name="checkversion">
987 <if>
988 <contains string="${version}" substring="SNAPSHOT" />
989 <then>
990 <fail message="Error: cannot release a snapshot. Set -Dversion" />
991 </then>
992 </if>
993 </target>
994
995 <target name="relnotes-uptodate" depends="init">
996 <!-- releasenotes are considered up-to-date if they exist. -->
997 <available property="relnotes.exists" file="${relnotes.filename}" />
998
999 <!-- if we're building a snapshot release, don't make release notes. -->
1000 <if>
1001 <contains string="${version}" substring="SNAPSHOT" />
1002 <then>
1003 <property name="relnotes.exists" value="true" />
1004 </then>
1005 </if>
1006 </target>
1007
1008 <target name="relnotes" depends="relnotes-uptodate" unless="relnotes.exists"
1009 description="Generate release notes">
1010 <exec executable="${python}" failonerror="yes">
1011 <arg value="${script.src.dir}/relnotes.py" />
1012 <arg value="${build.relnotes.dir}" />
1013 <arg value="${basedir}" />
1014 <arg value="${prev.git.hash}..HEAD" />
1015 <arg value="${version}" />
1016 <arg value="${oldversion}" />
1017 </exec>
1018 </target>
1019
1020 <target name="release" depends="checkversion,tar,releaseaudit"
1021 description="Roll a release artifact">
1022 <echo message="Release complete" />
1023 <echo message="Binary tar: ${tar.file}" />
1024 <echo message="Documentation: ${build.dir}/docs" />
1025 <echo message="Release notes: ${relnotes.filename}" />
1026 <echo message="Release audit report: ${build.dir}/rat.log" />
1027 </target>
1028
1029 <target name="mvn-prep" depends="init,ivy-resolve-test">
1030 <!-- prepare for mvn tasks. -->
1031
1032 <!-- Download maven -->
1033 <mkdir dir="${build.dir}" />
1034 <get src="${mvn_repo_url}" dest="${mvn.jar}" usetimestamp="true" />
1035
1036 <!-- Register mvn tasks -->
1037 <path id="mvn-ant-task.classpath" path="${mvn.jar}" />
1038 <typedef resource="org/apache/maven/artifact/ant/antlib.xml"
1039 uri="urn:maven-artifact-ant"
1040 classpathref="mvn-ant-task.classpath"/>
1041
1042 <!-- generate our poms from our ivy files. -->
1043 <mkdir dir="${mvn.build.dir}" />
1044 <ivy:makepom ivyfile="ivy/sqoop.xml" pomfile="${sqoop.pom}"
1045 settingsRef="${name}.ivy.settings">
1046 <mapping conf="default" scope="compile" />
1047 <mapping conf="runtime" scope="runtime" />
1048 </ivy:makepom>
1049 <ivy:makepom ivyfile="ivy/sqoop-test.xml" pomfile="${sqooptest.pom}"
1050 settingsRef="${name}.ivy.settings">
1051 <mapping conf="default" scope="compile" />
1052 <mapping conf="runtime" scope="runtime" />
1053 </ivy:makepom>
1054
1055 <!-- Change the version in the pom file to reflect our claimed version. -->
1056 <replaceregexp>
1057 <regexp pattern="&lt;version&gt;.*&lt;/version&gt;" />
1058 <substitution expression="&lt;version&gt;${version}&lt;/version&gt;" />
1059 <fileset dir="${mvn.build.dir}">
1060 <include name="*.pom" />
1061 </fileset>
1062 </replaceregexp>
1063 </target>
1064
1065 <target name="srcjars" depends="init,jar-all"
1066 description="Create source jars">
1067 <mkdir dir="${build.srcjar.dir}" />
1068 <jar jarfile="${build.srcjar.dir}/${artifact.name}-sources.jar">
1069 <fileset dir="${src.dir}" />
1070 <fileset dir="${build.src.dir}" />
1071 </jar>
1072 <jar jarfile="${build.srcjar.dir}/${name}-test-${version}-sources.jar">
1073 <fileset dir="${test.dir}" />
1074 </jar>
1075 </target>
1076
1077 <target name="mvn-install" depends="init,mvn-prep,jar-all,srcjars"
1078 description="Install Sqoop in local m2 repository">
1079 <artifact:pom file="${sqoop.pom}" id="sqoop" />
1080 <artifact:install file="${build.dir}/${dest.jar}">
1081 <pom refid="sqoop" />
1082 <attach file="${build.srcjar.dir}/${artifact.name}-sources.jar"
1083 classifier="sources" />
1084 </artifact:install>
1085
1086 <artifact:pom file="${sqooptest.pom}" id="sqoop-test" />
1087 <artifact:install file="${build.dir}/${test.jar}">
1088 <pom refid="sqoop-test" />
1089 <attach file="${build.srcjar.dir}/${name}-test-${version}-sources.jar"
1090 classifier="sources" />
1091 </artifact:install>
1092 </target>
1093
1094 <target name="mvn-deploy" depends="init,mvn-prep,jar-all,srcjars"
1095 description="Deploy Sqoop to public maven repository">
1096 <artifact:pom file="${sqoop.pom}" id="sqoop" />
1097 <artifact:deploy file="${build.dir}/${dest.jar}">
1098 <remoteRepository id="${mvn.repo.id}" url="${mvn.deploy.url}"/>
1099 <pom refid="sqoop" />
1100 <attach file="${build.srcjar.dir}/${artifact.name}-sources.jar"
1101 classifier="sources" />
1102 </artifact:deploy>
1103
1104 <artifact:pom file="${sqooptest.pom}" id="sqoop-test" />
1105 <artifact:deploy file="${build.dir}/${test.jar}">
1106 <remoteRepository id="${mvn.repo.id}" url="${mvn.deploy.url}"/>
1107 <pom refid="sqoop-test" />
1108 <attach file="${build.srcjar.dir}/${name}-test-${version}-sources.jar"
1109 classifier="sources" />
1110 </artifact:deploy>
1111
1112 </target>
1113
1114 <target name="docs" depends="real-docs,relnotes,javadoc"
1115 description="Build documentation"/>
1116
1117 <target name="real-docs" depends="docs-uptodate,init" unless="skip-real-docs">
1118 <exec executable="make" failonerror="true">
1119 <arg value="-C" />
1120 <arg value="${basedir}/src/docs" />
1121 <arg value="BUILDROOT=${build.dir}" />
1122 <arg value="VERSION=${version}" />
1123 </exec>
1124 <touch file="${build.docs.timestamp}" />
1125 </target>
1126
1127 <target name="javadoc-uptodate" depends="init">
1128 <uptodate property="javadoc.is.uptodate">
1129 <srcfiles dir="${src.dir}">
1130 <include name="**/*.java" />
1131 <include name="**/*.html" />
1132 </srcfiles>
1133 <mapper type="merge" to="${build.javadoc}/index.html" />
1134 </uptodate>
1135 </target>
1136
1137 <target name="javadoc" description="Build javadoc"
1138 depends="init,javadoc-uptodate,compile" unless="javadoc.is.uptodate">
1139 <mkdir dir="${build.javadoc}" />
1140 <exec executable="date" outputproperty="year">
1141 <arg value="+%Y" />
1142 </exec>
1143 <javadoc
1144 destdir="${build.javadoc}"
1145 author="true"
1146 version="true"
1147 use="true"
1148 windowtitle="${Name} ${version} API"
1149 doctitle="${Name} ${version} API"
1150 bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
1151 <packageset dir="${src.dir}">
1152 <include name="org/apache/sqoop/lib/**" />
1153 </packageset>
1154 <classpath>
1155 <path refid="compile.classpath" />
1156 </classpath>
1157 </javadoc>
1158 </target>
1159
1160 <target name="checkfailure" depends="test-core" if="tests.failed">
1161 <touch file="${build.dir}/testsfailed"/>
1162 <fail unless="continueOnFailure">Unit tests failed!</fail>
1163 </target>
1164
1165 <target name="clean" description="Clean build target files">
1166 <delete dir="${build.dir}"/>
1167 </target>
1168
1169 <target name="clean-cache" description="Remove cached dependencies">
1170 <delete dir="${user.home}/.ivy2/cache/org.apache.hadoop" />
1171 <delete dir="${user.home}/.ivy2/cache/com.cloudera.hadoop" />
1172 <delete dir="${user.home}/.ivy2/cache/com.cloudera.hadoop" />
1173 <delete file="${ivy.jar}" />
1174 </target>
1175
1176 <target name="veryclean"
1177 depends="clean,clean-cache"
1178 description="Clean build and remove cached dependencies">
1179 </target>
1180
1181 <target name="findbugs" depends="check-for-findbugs,jar,compile-test"
1182 if="findbugs.present" description="Run FindBugs">
1183 <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
1184 classpath="${findbugs.home}/lib/findbugs-ant.jar" />
1185 <mkdir dir="${findbugs.out.dir}"/>
1186 <findbugs home="${findbugs.home}" output="xml:withMessages"
1187 outputFile="${findbugs.output.xml.file}" effort="max"
1188 jvmargs="-Xms512m -Xmx512m">
1189 <auxClasspath>
1190 <path refid="test.classpath"/>
1191 </auxClasspath>
1192 <sourcePath path="${src.dir}" />
1193 <sourcePath path="${test.dir}" />
1194 <class location="${build.dir}/${dest.jar}" />
1195 <class location="${build.test.classes}" />
1196 </findbugs>
1197 <xslt style="${findbugs.home}/src/xsl/default.xsl"
1198 in="${findbugs.output.xml.file}"
1199 out="${findbugs.output.html.file}" />
1200 </target>
1201
1202 <target name="warn-findbugs-unset" unless="findbugs.home">
1203 <fail message="You need to set -Dfindbugs.home=/path/to/findbugs" />
1204 </target>
1205
1206 <target name="check-for-findbugs" depends="warn-findbugs-unset">
1207 <available property="findbugs.present"
1208 file="${findbugs.home}/lib/findbugs.jar" />
1209 </target>
1210
1211 <target name="cobertura"
1212 depends="check-for-cobertura,warn-cobertura-unset,jar,compile-test,test-prep"
1213 if="cobertura.present" description="Run Cobertura (code coverage)">
1214 <taskdef classpathref="cobertura.classpath"
1215 resource="tasks.properties"/>
1216 <mkdir dir="${cobertura.class.dir}" />
1217 <cobertura-instrument todir="${cobertura.class.dir}"
1218 datafile="${cobertura.dir}/cobertura-${cobertura.testset}.ser">
1219 <fileset dir="${build.classes}">
1220 <include name="**/*.class" />
1221 </fileset>
1222 </cobertura-instrument>
1223
1224 <!-- Run the unit tests, but do not fail the build if tests fail. -->
1225 <antcall target="test-core" inheritRefs="true" />
1226
1227 <!-- merge the reports together from the internal and thirdparty tests -->
1228 <delete file="${cobertura.dir}/cobertura.ser" />
1229 <cobertura-merge datafile="${cobertura.dir}/cobertura.ser">
1230 <fileset dir="${cobertura.dir}">
1231 <include name="*.ser" />
1232 </fileset>
1233 </cobertura-merge>
1234 <delete dir="${cobertura.report.dir}" />
1235 <cobertura-report srcdir="${src.dir}" destdir="${cobertura.report.dir}"
1236 format="${cobertura.format}"
1237 datafile="${cobertura.dir}/cobertura.ser" />
1238 </target>
1239
1240 <target name="warn-cobertura-unset" depends="check-for-cobertura"
1241 unless="cobertura.present">
1242 <fail message="You need to set -Dcobertura.home=/path/to/cobertura" />
1243 </target>
1244
1245 <target name="check-for-cobertura">
1246 <available property="cobertura.present"
1247 file="${cobertura.home}/cobertura.jar" />
1248 </target>
1249
1250 <target name="checkstyle" depends="ivy-retrieve-checkstyle,compile-all"
1251 description="Check source code conventions">
1252 <taskdef resource="checkstyletask.properties">
1253 <classpath refid="${name}.checkstyle.classpath" />
1254 </taskdef>
1255
1256 <mkdir dir="${checkstyle.report.dir}" />
1257 <checkstyle config="${checkstyle.xml}" failOnViolation="false">
1258 <fileset dir="${base.src.dir}" includes="**/*.java" />
1259 <classpath refid="test.classpath"/>
1260 <formatter type="xml"
1261 toFile="${checkstyle.report.dir}/checkstyle-errors.xml" />
1262 </checkstyle>
1263
1264 <xslt style="${checkstyle.format.xsl}"
1265 in="${checkstyle.report.dir}/checkstyle-errors.xml"
1266 out="${checkstyle.report.dir}/checkstyle-errors.html" />
1267 </target>
1268
1269 <target name="ivy-probe-antlib" >
1270 <condition property="ivy.found">
1271 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
1272 </condition>
1273 </target>
1274
1275 <!-- Downloads the ivy jar itself. -->
1276 <target name="ivy-download" unless="offline">
1277 <mkdir dir="${lib.dir}" />
1278 <get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
1279 </target>
1280
1281 <target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib"
1282 unless="ivy.found">
1283 <typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
1284 loaderRef="ivyLoader">
1285 <classpath>
1286 <pathelement location="${ivy.jar}"/>
1287 </classpath>
1288 </typedef>
1289 <fail >
1290 <condition >
1291 <not>
1292 <typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
1293 </not>
1294 </condition>
1295 You need Apache Ivy 2.0 or later from http://ant.apache.org/
1296 It could not be loaded from ${ivy_repo_url}
1297 </fail>
1298 </target>
1299
1300 <target name="ivy-init" depends="ivy-init-antlib" unless="ivy.configured">
1301 <ivy:configure settingsid="${name}.ivy.settings" file="${ivysettings.xml}"/>
1302 <property name="ivy.configured" value="true" />
1303 </target>
1304
1305
1306 <!-- retrieve ivy-managed artifacts for the compile configuration -->
1307 <target name="ivy-resolve-common" depends="ivy-init">
1308 <ivy:resolve settingsRef="${name}.ivy.settings" conf="common" />
1309 </target>
1310 <target name="ivy-retrieve-common" depends="ivy-resolve-common">
1311 <ivy:retrieve settingsRef="${name}.ivy.settings"
1312 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
1313 <ivy:cachepath pathid="${name}.common.classpath" conf="common" />
1314 </target>
1315
1316
1317 <!-- retrieve ivy-managed artifacts for the test configuration -->
1318 <target name="ivy-resolve-test" depends="ivy-init">
1319 <ivy:resolve settingsRef="${name}.ivy.settings" conf="test" />
1320 </target>
1321 <target name="ivy-retrieve-test" depends="ivy-resolve-test">
1322 <ivy:retrieve settingsRef="${name}.ivy.settings"
1323 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
1324 <ivy:cachepath pathid="${name}.test.classpath" conf="test" />
1325 </target>
1326
1327
1328 <!-- retrieve ivy-managed artifacts for the redist configuration -->
1329 <target name="ivy-resolve-redist" depends="ivy-init">
1330 <ivy:resolve settingsRef="${name}.ivy.settings" conf="redist" />
1331 </target>
1332 <target name="ivy-retrieve-redist" depends="ivy-resolve-redist">
1333 <ivy:retrieve settingsRef="${name}.ivy.settings"
1334 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
1335 <ivy:cachepath pathid="${name}.redist.classpath" conf="redist" />
1336 </target>
1337
1338 <!-- retrieve ivy-managed artifacts from the Hadoop distribution -->
1339 <target name="ivy-resolve-hadoop" depends="ivy-init"
1340 unless="hadoop.is.local">
1341 <ivy:resolve settingsRef="${name}.ivy.settings" conf="common" />
1342 </target>
1343 <target name="ivy-retrieve-hadoop" depends="ivy-init,ivy-resolve-hadoop">
1344 <!-- retrieve hadoop refs normally. -->
1345 <ivy:retrieve settingsRef="${name}.ivy.settings"
1346 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}"
1347 sync="true" />
1348 <ivy:cachepath pathid="${name}.hadoop.classpath" conf="common" />
1349 </target>
1350
1351 <!-- retrieve ivy-managed test artifacts from the Hadoop distribution -->
1352 <target name="ivy-resolve-hadoop-test" depends="ivy-init"
1353 unless="hadoop.is.local">
1354 <ivy:resolve settingsRef="${name}.ivy.settings" conf="test" />
1355 </target>
1356 <target name="ivy-retrieve-hadoop-test"
1357 depends="ivy-init,ivy-resolve-hadoop-test">
1358 <ivy:retrieve settingsRef="${name}.ivy.settings"
1359 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}"
1360 sync="true" />
1361 <ivy:cachepath pathid="${name}.hadooptest.classpath"
1362 conf="test" />
1363 </target>
1364
1365 <!-- retrieve ivy-managed artifacts for checkstyle -->
1366 <target name="ivy-resolve-checkstyle" depends="ivy-init">
1367 <ivy:resolve settingsRef="${name}.ivy.settings" conf="checkstyle" />
1368 </target>
1369 <target name="ivy-retrieve-checkstyle" depends="ivy-resolve-checkstyle">
1370 <ivy:retrieve settingsRef="${name}.ivy.settings"
1371 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
1372 <ivy:cachepath pathid="${name}.checkstyle.classpath" conf="checkstyle" />
1373 </target>
1374
1375 <!-- retrieve ivy-managed artifacts for releaseaudit -->
1376 <target name="ivy-resolve-releaseaudit" depends="ivy-init">
1377 <ivy:resolve settingsRef="${name}.ivy.settings" conf="releaseaudit" />
1378 </target>
1379 <target name="ivy-retrieve-releaseaudit" depends="ivy-resolve-releaseaudit">
1380 <ivy:retrieve settingsRef="${name}.ivy.settings"
1381 pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
1382 <ivy:cachepath pathid="${name}.releaseaudit.classpath" conf="releaseaudit" />
1383 <available classname="${rat.reporting.classname}"
1384 classpathref="${name}.releaseaudit.classpath" property="rat.present"
1385 value="true" />
1386 </target>
1387
1388 <target name="eclipse" description="Generate Eclipse project"
1389 depends="init,ivy-retrieve-hadoop,ivy-retrieve-hadoop-test">
1390 <taskdef name="eclipse" classname="prantl.ant.eclipse.EclipseTask"
1391 classpath="${lib.dir}/ant-eclipse-1.0-jvm1.2.jar" />
1392 <eclipse failonerror="true" updatealways="true">
1393 <project name="${name}" />
1394 <classpath>
1395 <source path="src/java" />
1396 <source path="src/perftest" />
1397 <source path="src/test" />
1398 <output path="${build.dir}/eclipse-build" />
1399 <library pathref="test.classpath" />
1400 </classpath>
1401 </eclipse>
1402 </target>
1403
1404 <!-- Fault injection customization section -->
1405 <target name="justjar" depends="ivy-resolve-test">
1406 <echo message="Project: ${ant.project.name}" />
1407 <jar jarfile="${build.dir}/${test.jar}" basedir="${build.test.classes}"/>
1408 </target>
1409
1410 <target name="jar-fault-inject" depends="init, injectfaults"
1411 description="Make sqoop-fi.jar">
1412 <macro-jar-fault-inject
1413 target.name="justjar"
1414 build.dir="${build-fi.dir}"
1415 jar.final.name="final.name"
1416 jar.final.value="${final.name}-fi" />
1417 <copy todir="${lib.dir}">
1418 <fileset dir="${build-fi.dir}">
1419 <include name="*.jar"/>
1420 </fileset>
1421 </copy>
1422 </target>
1423
1424 <target name="jar-test-fault-inject" depends="init, injectfaults"
1425 description="Make sqoop-test-fi.jar">
1426 <macro-jar-test-fault-inject
1427 target.name="test-jar"
1428 jar.final.name="test.final.name"
1429 jar.final.value="${test.final.name}-fi" />
1430 </target>
1431
1432 <target name="run-fault-inject-with-testcaseonly" depends="init, injectfaults">
1433 <fail unless="testcase">Can't run this target without -Dtestcase setting!
1434 </fail>
1435 <macro-run-tests-fault-inject target.name="test"
1436 testcasesonly="true"/>
1437 </target>
1438
1439 <target name="run-test-core-fault-inject" depends="init, injectfaults"
1440 description="Run full set of the unit tests with fault injection">
1441 <macro-run-tests-fault-inject target.name="test"
1442 testcasesonly="false"/>
1443 </target>
1444
1445 <target name="report" depends="ivy-resolve-hadoop">
1446 <mkdir dir="build/report"/>
1447 <ivy:report todir="build/report" xsl="false" />
1448 </target>
1449
1450 </project>