<?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 default="main" basedir=".">
    <property name="Name" value="gridmix"/>
    <property name="version" value="0.1"/>
    <property name="final.name" value="${name}-${version}"/>
    <property name="hadoop.dir" value="${basedir}/../../../"/>
    <property name="lib.dir" value="${hadoop.dir}/lib"/>
    <property name="src.dir" value="${basedir}/src"/>
    <property name="conf.dir" value="${basedir}/conf"/>
    <property name="docs.dir" value="${basedir}/docs"/>
    <property name="build.dir" value="${basedir}/build"/>
    <property name="dist.dir" value="${basedir}/dist"/>
    <property name="build.classes" value="${build.dir}/classes"/>
	
    <target name="init">
        <mkdir dir="${build.dir}"/>
        <mkdir dir="${dist.dir}"/>
    </target>

    <target name="main" depends="init, compile, compress" description="Main target">
        <echo>
            Building the .jar files.
        </echo>
    </target>
  
    <target name="compile" depends="init" description="Compilation target">
        <javac srcdir="src/java/" destdir="${build.dir}">
        	<classpath refid="classpath" />
        </javac>
    </target>

    <target name="dev-build" depends="init, dev-compile, compress" description="Developers build target">
        <echo>
            Building the .jar files.
        </echo>
    </target>

    <target name="dev-compile" depends="init" description="Compilation target">
        <path id="dev-classpath">
            <pathelement location="${build.classes}"/>
            <fileset dir="${hadoop.dir}/build">
               <include name="**.jar" />
               <include name="contrib/streaming/**.jar" />
            </fileset>
            <fileset dir="${lib.dir}">
               <include name="*.jar" />
               <exclude name="**/excluded/" />
            </fileset>
         </path>
        <javac srcdir="src/java/" destdir="${build.dir}" classpathref="dev-classpath"/>
    </target>

    <target name="compress" depends="compile" description="Compression target">
        <jar jarfile="${build.dir}/gridmix.jar" basedir="${build.dir}" includes="**/*.class" />
        <copy todir="." includeEmptyDirs="false">
            <fileset dir="${build.dir}">
	        <exclude name="**" />
	        <include name="**/*.jar" />
            </fileset>
        </copy>
    </target>

  
    <!-- ================================================================== -->
    <!-- Clean.  Delete the build files, and their directories              -->
    <!-- ================================================================== -->
    <target name="clean" description="Clean.  Delete the build files, and their directories">
      <delete dir="${build.dir}"/>
      <delete dir="${dist.dir}"/>
    </target>

    <!-- the normal classpath -->
    <path id="classpath">
	    <pathelement location="${build.classes}"/>
	    <fileset dir="${lib.dir}">
	       <include name="*.jar" />
	       <exclude name="**/excluded/" />
	    </fileset>
	    <fileset dir="${hadoop.dir}">
	       <include name="**.jar" />
           <include name="contrib/streaming/*.jar" />
	    </fileset>
    </path>
</project>
