blob: cbfba5a54c3407c7aa6f4ed7245a64d8007dfc3b [file] [log] [blame]
<?xml version="1.0"?>
<!--
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.
-->
<!--
Before you can run these subtargets directly, you need
to call at top-level: ant deploy-contrib compile-core-test
-->
<project xmlns:ivy="antlib:org.apache.ivy.ant" name="shims" default="jar">
<import file="../build-common.xml"/>
<!-- default list of shims to build -->
<property name="shims.include" value="0.20,0.20S,0.23"/>
<property name="shims.common.sources" value="${basedir}/src/common/java"/>
<property name="shims.common.secure.sources" value="${basedir}/src/common/java;${basedir}/src/common-secure/java"/>
<!-- sources and hadoop version for each shim -->
<property name="shims.0.20.sources" value="${shims.common.sources};${basedir}/src/0.20/java" />
<property name="shims.0.20.version" value="${hadoop-0.20.version}" />
<property name="shims.0.20S.sources" value="${shims.common.secure.sources};${basedir}/src/0.20S/java" />
<property name="shims.0.20S.version" value="${hadoop-0.20S.version}" />
<property name="shims.0.23.sources" value="${shims.common.secure.sources};${basedir}/src/0.23/java" />
<property name="shims.0.23.version" value="${hadoop-0.23.version}" />
<property name="shims.0.20.hadoop.ivy.dir" value="${hive.root}/build/ivy/lib/hadoop0.20.shim" />
<property name="shims.0.20S.hadoop.ivy.dir" value="${hive.root}/build/ivy/lib/hadoop0.20S.shim" />
<property name="shims.0.23.hadoop.ivy.dir" value="${hive.root}/build/ivy/lib/hadoop0.23.shim" />
<target name="build-shims"
description="Build shims against a particular hadoop version">
<echo message="Project: ${ant.project.name}"/>
<echo message="Compiling ${sources} against hadoop ${hadoop.version.ant-internal} (${hadoop.root})"/>
<antcall target="ivy-retrieve-hadoop-shim" inheritRefs="false" inheritAll="false">
<param name="ivy.hadoop.shim.conf" value="hadoop${shim.name}.shim" />
</antcall>
<path id="shims.classpath">
<fileset dir="${hadoop.ivy.dir}" includes="*.jar" />
<fileset dir="../lib" includes="*.jar" />
<fileset dir="${hive.root}/build/ivy/lib/default" includes="*.jar" />
</path>
<javac
encoding="${build.encoding}"
includes="**/*.java"
destdir="${build.classes}"
debug="${javac.debug}"
deprecation="${javac.deprecation}"
srcdir="${sources}"
includeantruntime="false">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="shims.classpath"/>
</javac>
</target>
<target name="compile" depends="init,ivy-retrieve">
<echo message="Project: ${ant.project.name}"/>
<for param="shimName" list="${shims.include}">
<sequential>
<echo>Building shims @{shimName}</echo>
<antcall target="build-shims" inheritRefs="false" inheritAll="false">
<param name="hadoop.version.ant-internal" value="${shims.@{shimName}.version}" />
<param name="sources" value="${shims.@{shimName}.sources}" />
<param name="hadoop.ivy.dir" value="${shims.@{shimName}.hadoop.ivy.dir}" />
<param name="shim.name" value="@{shimName}" />
</antcall>
</sequential>
</for>
</target>
<target name="compile-test-worker"
description="worker to compile tests, takes worker.test.src.dir parameter"
depends="set-test-classpath">
<echo message="Project: ${ant.project.name}"/>
<echo message="Compiling shim tests against hadoop ${hadoop.mr.rev}"/>
<if>
<available file="${worker.test.src.dir}" type="dir"/>
<then>
<echo message=" Test srcdir : ${worker.test.src.dir} "/>
<javac
encoding="${build.encoding}"
srcdir="${worker.test.src.dir}"
includes="org/apache/hadoop/**/*.java"
excludes="**/TestSerDe.java"
destdir="${test.build.classes}"
debug="${javac.debug}"
optimize="${javac.optimize}"
deprecation="${javac.deprecation}"
includeantruntime="false">
<compilerarg line="${javac.args} ${javac.args.warnings}" />
<classpath refid="test.classpath"/>
</javac>
</then>
<else>
<echo message=" Skipping nonexistent test srcdir : ${worker.test.src.dir} "/>
</else>
</if>
</target>
<target name="determine-versions-for-tests">
<condition property="is.20">
<equals arg1="${hadoop.mr.rev}" arg2="20" />
</condition>
<condition property="is.20S">
<equals arg1="${hadoop.mr.rev}" arg2="20S" />
</condition>
<condition property="is.23">
<equals arg1="${hadoop.mr.rev}" arg2="23" />
</condition>
<condition property="is.secure">
<or>
<istrue value="${is.20S}" />
<istrue value="${is.23}" />
</or>
</condition>
</target>
<target name="compile-23-test" if="is.23">
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/0.23/test" />
</antcall>
</target>
<target name="compile-20S-test" if="is.20S">
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/0.20S/test" />
</antcall>
</target>
<target name="compile-20-test" if="is.20">
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/0.20/test" />
</antcall>
</target>
<target name="compile-common-secure-test" if="is.secure">
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/common-secure/test" />
</antcall>
</target>
<target name="compile-common-test">
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/test" />
</antcall>
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${basedir}/src/common/test" />
</antcall>
<antcall target="compile-test-worker" inheritRefs="false" inheritAll="false">
<param name="worker.test.src.dir" value="${test.build.src}" />
</antcall>
</target>
<target name="compile-test" depends="compile,ivy-retrieve-test,determine-versions-for-tests">
<echo message="Project: ${ant.project.name}"/>
<antcall target="compile-common-test" />
<antcall target="compile-common-secure-test" />
<antcall target="compile-20-test" />
<antcall target="compile-20S-test" />
<antcall target="compile-23-test" />
</target>
</project>