<?xml version="1.0" encoding="UTF-8"?>

<!--
   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="hwi" default="jar">
  
  <property name="src.dir"  location="${basedir}/src/java"/>
  <import file="../build-common.xml"/>

  <!-- We include servlet jar in addition to the normal
       Hive classpath. Some HWI components are linked
       to the servlet libraries.  -->
  <path id="classpath-hwi">
    <fileset dir="${hadoop.root}">
      <include name="lib/**/*.jar" />
      <exclude name="lib/**/excluded/" />
      <!-- below is for 0.23 onwards -->
      <include name="share/hadoop/common/lib/*.jar" />
      <exclude name="share/hadoop/common/lib/hadoop-mapreduce-*.jar" />
      <exclude name="share/hadoop/common/lib/hadoop-yarn-*.jar" />
    </fileset>
    <path refid="classpath"/>
  </path>

  <!--hive_hwi.war file contains only the JSP sources -->
  <target name="war">
    <echo message="Project: ${ant.project.name}"/>
    <jar jarfile="${build.dir.hive}/hwi/hive-hwi-${version}.war" basedir="${basedir}/web">
      <manifest>
        <!-- Not putting these in their own manifest section, since that inserts
             a new-line, which breaks the reading of the attributes. -->
        <attribute name="Implementation-Title" value="Hive"/>
        <attribute name="Implementation-Version" value="${version}"/>
        <attribute name="Implementation-Vendor" value="Apache"/>
      </manifest>
      <metainf dir="${hive.root}" includes="LICENSE,NOTICE"/>
    </jar>
  </target>

  <!-- Compile is a clone of the build-common.xml compile, with one exception:
       We include the war target as a dependency. In this way the war target
       is called without changes to the upstream build infrastructure.
  -->
  <target name="compile" depends="init, setup, ivy-retrieve, war">
    <echo message="Project: ${ant.project.name}"/>
    <javac
     encoding="${build.encoding}"
     srcdir="${src.dir}"
     includes="**/*.java"
     destdir="${build.classes}"
     debug="${javac.debug}"
     deprecation="${javac.deprecation}">
      <compilerarg line="${javac.args} ${javac.args.warnings}" />
      <classpath refid="classpath"/>
    </javac>
  </target>

</project>
