blob: 03bcd950f6af4d0dad775e4e17e76625a9b4a5e6 [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.
-->
<project name="hcatalog" default="clientjar" xmlns:ivy="antlib:org.apache.ivy.ant" >
<!--
================================================================================
Properties and Classpaths Section
================================================================================
-->
<!-- name and version -->
<property name="hcatalog.version" value="0.1.1"/>
<property name="hcatalog.jar" value="${ant.project.name}-${hcatalog.version}.jar"/>
<property name="final.name" value="${ant.project.name}-${hcatalog.version}" />
<!-- hive properties -->
<property name="hive.root" value="${basedir}/hive/external"/>
<!-- build properties -->
<property name="lib.dir" value="${basedir}/lib/" />
<property name="src.dir" location="${basedir}/src/java"/>
<property name="docs.src" value="${basedir}/src/docs"/>
<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="dist.dir" value="${build.dir}/${final.name}" />
<!-- javac properties -->
<property name="build.encoding" value="UTF8" />
<property name="excludes" value=""/>
<property name="javac.debug" value="on" />
<property name="javac.optimize" value="on" />
<property name="javac.deprecation" value="off" />
<property name="javac.version" value="1.6" />
<property name="javac.args" value="" />
<!-- test properties -->
<property name="test.src.dir" value="${basedir}/src/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="2700000" />
<property name="test.junit.output.format" value="plain" />
<property name="test.all.file" value="${test.src.dir}/all-tests"/>
<property name="test.exclude.file" value="${test.src.dir}/excluded-tests"/>
<property name="test.output" value="no"/>
<property name="hive.conf.dir" value="${hive.root}/conf"/>
<property name="test.warehouse.dir" value="/tmp/hcat_junit_warehouse"/>
<!-- ivy properteis set here -->
<property name="ivy.repo.dir" value="${user.home}/ivyrepo" />
<property name="ivy.dir" location="ivy" />
<loadproperties srcfile="${ivy.dir}/libraries.properties"/>
<property name="asfrepo" value="https://repository.apache.org"/>
<property name="asfsnapshotrepo" value="${asfrepo}/content/repositories/snapshots"/>
<property name="mvnrepo" value="http://repo2.maven.org/maven2"/>
<property name="asfstagingrepo" value="${asfrepo}/service/local/staging/deploy/maven2"/>
<property name="ivy.jar" location="${ivy.dir}/ivy-${ivy.version}.jar"/>
<property name="ant_task.jar" location="${ivy.dir}/maven-ant-tasks-${ant-task.version}.jar"/>
<property name="ant_task_repo_url"
value="${mvnrepo}/org/apache/maven/maven-ant-tasks/${ant-task.version}/maven-ant-tasks-${ant-task.version}.jar"/>
<property name="ivy_repo_url" value="${mvnrepo}/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar"/>
<property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml" />
<property name="build.ivy.dir" location="${build.dir}/ivy" />
<property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib" />
<property name="ivy.lib.dir" location="${build.ivy.lib.dir}/${ant.project.name}"/>
<property name="build.ivy.report.dir" location="${build.ivy.dir}/report" />
<!-- rats properties -->
<property name="rat.reporting.classname" value="rat.Report"/>
<!--this is the naming policy for artifacts we want pulled down-->
<property name="ivy.artifact.retrieve.pattern" value="${ant.project.name}/[artifact]-[revision](-[classifier]).[ext]"/>
<!-- Classpaths for various builds -->
<path id="classpath">
<fileset dir="${hive.root}" includes="testlibs/*.jar"/>
<fileset dir="${hive.root}" includes="testlibs/*.jar"/>
<fileset dir="${hive.root}/lib" includes="*.jar"/>
<fileset dir="${hive.root}/build/cli" includes="*.jar"/>
<fileset dir="${hive.root}/build/common" includes="*.jar"/>
<fileset dir="${hive.root}/build/serde" includes="*.jar"/>
<fileset dir="${hive.root}/build/metastore" includes="*.jar"/>
<fileset dir="${hive.root}/build/ql" includes="*.jar"/>
<fileset dir="${hive.root}/ql/lib" includes="antlr-3.0.1.jar"/>
<fileset dir="${hive.root}/build/hadoopcore/hadoop-0.20.3-CDH3-SNAPSHOT/"
includes="hadoop-core-0.20.3-CDH3-SNAPSHOT.jar"/>
<fileset dir="${ivy.lib.dir}" includes="*.jar"/>
</path>
<path id="test.classpath">
<pathelement location="${test.build.classes}" />
<pathelement location="${build.classes}" />
<pathelement location="conf"/>
<pathelement location="${hive.conf.dir}"/>
<!-- jars Hive depends on -->
<fileset dir="${hive.root}/build/ivy/lib/default/">
<include name="**/*.jar" />
</fileset>
<!-- jars Hadoop depends on -->
<fileset dir="${hive.root}/build/hadoopcore/hadoop-0.20.3-CDH3-SNAPSHOT/lib/" >
<include name="**/*.jar" />
</fileset>
<!--
<pathelement location="${test.src.data.dir}/conf"/>
<pathelement location="${hadoop.oldstyle-name.test.jar}"/>
<pathelement location="${hadoop.newstyle-name.test.jar}"/>
<pathelement location="${common.jar}"/>
<pathelement location="${jsp.test.jar}"/>
-->
<pathelement location="${hcatalog.jar}"/>
<!--
<pathelement location="${hadoop.root}/lib/jsp-2.1/jsp-api-2.1.jar"/>
-->
<path refid="classpath"/>
<fileset dir="${hive.root}/build/hadoopcore/hadoop-0.20.3-CDH3-SNAPSHOT/"
includes="hadoop-test-0.20.3-CDH3-SNAPSHOT.jar"/>
</path>
<!--
================================================================================
Ivy Section
================================================================================
-->
<!-- Ivy goop stolen directly from Pig's build.xml -->
<target name="ivy-init-dirs">
<mkdir dir="${build.ivy.dir}" />
<mkdir dir="${build.ivy.lib.dir}" />
<mkdir dir="${build.ivy.report.dir}" />
</target>
<target name="ivy-probe-antlib" >
<condition property="ivy.found">
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
</condition>
</target>
<target name="ivy-download" description="To download ivy" unless="offline">
<get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
</target>
<!--
To avoid Ivy leaking things across big projects, always load Ivy in the same classloader.
Also note how we skip loading Ivy if it is already there, just to make sure all is well.
-->
<target name="ivy-init-antlib" depends="ivy-download,ivy-init-dirs,ivy-probe-antlib" unless="ivy.found">
<typedef uri="antlib:org.apache.ivy.ant" onerror="fail" loaderRef="ivyLoader">
<classpath>
<pathelement location="${ivy.jar}"/>
</classpath>
</typedef>
<fail>
<condition >
<not>
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
</not>
</condition>
You need Apache Ivy 2.0 or later from http://ant.apache.org/
It could not be loaded from ${ivy_repo_url}
</fail>
</target>
<target name="ivy-init" depends="ivy-init-antlib" >
<!--Configure Ivy by reading in the settings file
If anyone has already read in a settings file into this settings ID, it gets priority
-->
<ivy:configure settingsid="${ant.project.name}.ivy.settings"
file="${ivysettings.xml}" override='false'/>
</target>
<target name="ivy-compile" depends="ivy-init" description="Resolve, Retrieve Ivy-managed artifacts for compile configuration">
<ivy:resolve settingsRef="${ant.project.name}.ivy.settings" conf="common"/>
<ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" conf="common"/>
<ivy:cachepath pathid="compile.classpath" conf="common"/>
</target>
<target name="ivy-releaseaudit" depends="ivy-init" description="Resolve, Retrieve Ivy-managed artifacts for releaseaudit configuration">
<ivy:resolve settingsRef="${ant.project.name}.ivy.settings" conf="releaseaudit"/>
<ivy:retrieve settingsRef="${ant.project.name}.ivy.settings"
pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" conf="releaseaudit"/>
<ivy:cachepath pathid="releaseaudit.classpath" conf="releaseaudit"/>
</target>
<target name="init" depends="ivy-compile" >
<mkdir dir="${dist.dir}" />
<mkdir dir="${build.classes}" />
<mkdir dir="${test.build.classes}" />
</target>
<!-- Build the external hive code -->
<target name="hive.jar">
<ant antfile="build.xml" dir="${hive.root}" target="jar"/>
</target>
<!--
================================================================================
Main Build and Jar Section
================================================================================
-->
<!-- Build HCatalog src files -->
<target name="compile-src" depends="hive.jar,init">
<javac encoding="${build.encoding}" srcdir="${src.dir}" excludes="${excludes}"
includes="**/*.java" destdir="${build.classes}" debug="${javac.debug}"
optimize="${javac.optimize}" target="${javac.version}"
source="${javac.version}" deprecation="${javac.deprecation}"
includeantruntime="false">
<compilerarg line="${javac.args}"/>
<classpath refid="classpath" />
</javac>
</target>
<!-- Build the hcatalog client jar -->
<target name="clientjar" depends="compile-src">
<jar jarfile="${build.dir}/${ant.project.name}/${hcatalog.jar}" basedir="${build.classes}">
</jar>
</target>
<!--
================================================================================
Test Section
================================================================================
-->
<!-- Build HCatalog test files -->
<target name="compile-test" depends="clientjar">
<javac encoding="${build.encoding}" srcdir="${test.src.dir}" excludes="${excludes}"
includes="**/*.java" destdir="${test.build.classes}" debug="${javac.debug}"
optimize="${javac.optimize}" target="${javac.version}"
source="${javac.version}" deprecation="${javac.deprecation}"
includeantruntime="false">
<compilerarg line="${javac.args}"/>
<classpath refid="test.classpath" />
</javac>
</target>
<!-- Run the unit tests -->
<target name="test" depends="compile-test">
<sequential>
<!-- If anyone knows how to set umask inside ant please do so -->
<exec executable="bin/umaskcheck.sh" failonerror="true"/>
<delete dir="${test.log.dir}"/>
<delete dir="${test.warehouse.dir}"/>
<mkdir dir="${test.log.dir}"/>
<mkdir dir="${test.warehouse.dir}"/>
<junit showoutput="${test.output}" printsummary="yes" haltonfailure="no"
fork="yes" maxmemory="512m" dir="${basedir}" timeout="${test.timeout}"
errorProperty="tests.failed" failureProperty="tests.failed">
<sysproperty key="hadoop.log.dir" value="${test.log.dir}"/>
<sysproperty key="hive.metastore.warehouse.dir" value="${test.warehouse.dir}"/>
<classpath>
<pathelement location="${test.build.classes}" />
<pathelement location="." />
<path refid="test.classpath"/>
</classpath>
<formatter type="${test.junit.output.format}" />
<!-- If the user has not defined a particular test to run, run them all -->
<batchtest fork="yes" todir="${test.log.dir}" unless="testcase">
<fileset dir="src/test">
<patternset>
<includesfile name="${test.all.file}"/>
<excludesfile name="${test.exclude.file}"/>
</patternset>
</fileset>
</batchtest>
<!-- Run one test case. To use this define -Dtestcase=X on the command line -->
<batchtest fork="yes" todir="${test.log.dir}" if="testcase">
<fileset dir="src/test" includes="**/${testcase}.java"/>
</batchtest>
<assertions>
<enable />
</assertions>
</junit>
<fail if="tests.failed">Tests failed!</fail>
</sequential>
</target>
<!--
================================================================================
Clean Section
================================================================================
-->
<!-- Clean the external hive code -->
<target name="hive.clean">
<ant antfile="${hive.root}/build.xml" dir="${hive.root}" target="clean"/>
</target>
<!-- Clean up children -->
<target name="clean" depends="hive.clean" description="Cleanup build artifacts">
<delete dir="${build.dir}" />
<delete dir="${test.warehouse.dir}"/>
</target>
<!--
================================================================================
Docs Section
================================================================================
-->
<target name="docs" depends="javadoc, forrest.check" description="Generate forrest-based documentation. To use, specify -Dforrest.home=&lt;base of Apache Forrest installation&gt; on the command line." if="forrest.home">
<exec dir="${docs.src}" executable="${forrest.home}/bin/forrest"
failonerror="true">
</exec>
<copy todir="${build.docs}/">
<fileset dir="${docs.src}/build/site/" />
</copy>
</target>
<target name="forrest.check" unless="forrest.home" >
<fail message="'forrest.home' is not defined. Please pass -Dforrest.home=&lt;base of Apache Forrest installation&gt; to Ant on the command-line." />
</target>
<target name="javadoc" depends="clientjar" description="Create documentation">
<mkdir dir="${build.javadoc}" />
<javadoc overview="${src.dir}/../docs/overview.html" packagenames="org.apache.hcatalog.*" destdir="${build.javadoc}" author="true" version="true" use="true" windowtitle="HCatalog ${hcatalog.version} API" doctitle="HCatalog ${hcatalog.version} API" bottom="Copyright &amp;copy; ${year} The Apache Software Foundation">
<packageset dir="${src.dir}" />
<classpath>
<path refid="classpath" />
</classpath>
<group title="hcatalog" packages="org.apache.hcatalog.*" />
</javadoc>
</target>
<!--
===============================================================================
Distribution Section
===============================================================================
-->
<target name="package" depends="clientjar, docs" description="Create an HCatalog release">
<mkdir dir="${dist.dir}" />
<mkdir dir="${dist.dir}/lib" />
<mkdir dir="${dist.dir}/conf" />
<mkdir dir="${dist.dir}/bin" />
<mkdir dir="${dist.dir}/bin/ext" />
<mkdir dir="${dist.dir}/bin/ext/util" />
<mkdir dir="${dist.dir}/scripts" />
<mkdir dir="${dist.dir}/docs" />
<mkdir dir="${dist.dir}/docs/api" />
<mkdir dir="${dist.dir}/docs/jdiff"/>
<mkdir dir="${dist.dir}/license" />
<mkdir dir="${dist.dir}/hive" />
<mkdir dir="${dist.dir}/hive/external" />
<copy todir="${dist.dir}/lib" includeEmptyDirs="false">
<fileset dir="${lib.dir}"/>
<fileset dir="${build.dir}/${ant.project.name}/">
<include name="hcatalog-*.jar"/>
</fileset>
<fileset dir="hive/external/build/ivy/lib/default">
<include name="jdo2-api-*.jar"/>
<include name="log4j-*.jar"/>
<include name="slf4j-*.jar"/>
<include name="datanucleus-connectionpool-*.jar"/>
<include name="datanucleus-core-*.jar"/>
<include name="datanucleus-rdbms-*.jar"/>
<include name="datanucleus-enhancer-*.jar"/>
<include name="commons-cli-*.jar"/>
<include name="commons-pool-*.jar"/>
<include name="commons-dbcp-*.jar"/>
<include name="guava-*.jar"/>
</fileset>
<fileset dir="hive/external/build/shims">
<include name="hive-shims-*.jar"/>
</fileset>
<fileset dir="hive/external/build/common">
<include name="hive-common-*.jar"/>
</fileset>
<fileset dir="hive/external/build/cli">
<include name="hive-cli-*.jar"/>
</fileset>
<fileset dir="hive/external/build/service">
<include name="hive-service-*.jar"/>
</fileset>
<fileset dir="hive/external/build/serde">
<include name="hive-serde-*.jar"/>
</fileset>
<fileset dir="hive/external/build/ql">
<include name="hive-exec-*.jar"/>
</fileset>
<fileset dir="hive/external/build/metastore">
<include name="hive-metastore-*.jar"/>
</fileset>
<fileset dir="hive/external/lib">
<include name="commons-collections-*.jar"/>
<include name="commons-logging-*.jar"/>
<include name="commons-logging-api-*.jar"/>
<include name="commons-lang-*.jar"/>
<include name="asm-api-*.jar"/>
<include name="derby-*.jar"/>
<include name="thrift-fb303-*.jar"/>
</fileset>
<fileset dir="hive/external/cli/lib">
<include name="jline-*.jar"/>
</fileset>
<fileset dir="hive/external/ql/lib">
<include name="antlr-runtime-*.jar"/>
</fileset>
</copy>
<copy todir="${dist.dir}/ivy">
<fileset dir="ivy" />
</copy>
<copy todir="${dist.dir}/bin">
<fileset dir="bin/">
<include name="*.sh"/>
</fileset>
<fileset file="hive/external/bin/hive"/>
<fileset file="hive/external/bin/hive-config.sh"/>
</copy>
<copy todir="${dist.dir}/bin/ext">
<fileset file="hive/external/bin/ext/metastore.sh"/>
</copy>
<copy todir="${dist.dir}/bin/ext/util">
<fileset file="hive/external/bin/ext/util/execHiveCmd.sh"/>
</copy>
<copy todir="${dist.dir}/docs">
<fileset dir="${build.docs}" />
</copy>
<copy todir="${dist.dir}/conf">
<fileset dir="conf" />
<fileset file="hive/external/conf/hive-default.xml"/>
</copy>
<copy todir="${dist.dir}/scripts">
<fileset file="hive/external/metastore/scripts/upgrade/mysql/hive-schema-0.7.0.mysql.sql"/>
<fileset dir="scripts">
<include name="*.sh"/>
</fileset>
</copy>
<!-- Copy source files so the tar ball can build -->
<copy todir="${dist.dir}/src/java" includeEmptyDirs="true">
<fileset dir="${src.dir}" />
</copy>
<copy todir="${dist.dir}/src/test" includeEmptyDirs="true">
<fileset dir="${test.src.dir}" />
</copy>
<copy todir="${dist.dir}/src/docs" includeEmptyDirs="true">
<fileset dir="${docs.src}" />
</copy>
<copy todir="${dist.dir}/" file="build.xml" />
<copy todir="${dist.dir}/" file="ivy.xml" />
<copy todir="${dist.dir}/hive/external" includeEmptyDirs="true">
<fileset dir="${hive.root}">
<exclude name="build/**"/>
</fileset>
</copy>
<!-- Copy the licenses and such -->
<copy todir="${dist.dir}">
<fileset dir=".">
<include name="*.txt" />
</fileset>
</copy>
<copy todir="${dist.dir}/license">
<fileset dir="license" />
</copy>
<chmod perm="ugo+x" type="file">
<fileset dir="${dist.dir}/bin" />
</chmod>
</target>
<target name="releaseaudit" depends="ivy-releaseaudit, package" description="Release Audit activities">
<java classname="${rat.reporting.classname}" fork="true">
<classpath refid="releaseaudit.classpath"/>
<arg value="${build.dir}/${final.name}"/>
</java>
</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="${build.dir}" mode="664">
<exclude name="${final.name}/bin/*" />
<include name="${final.name}/**" />
</tarfileset>
<tarfileset dir="${build.dir}" mode="755">
<include name="${final.name}/bin/*" />
</tarfileset>
<tarfileset dir="${build.dir}" mode="755">
<include name="${final.name}/scripts/*" />
</tarfileset>
</tar>
</target>
</project>