<?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.
-->
<!-- 
Build file for org.apache.env.Which service. No dependencies.
@author shane_curcuru@us.ibm.com
-->
<project name="xml-commons-which" default="all" >

  <!-- Name and version information -->
  <property name="name.which" value="xml-commons-which"/>
  <property name="impl.name" value="XmlWhich"/>
  <!-- Version each utility separately -->
  <property name="impl.version" value="1.1.b1"/>

  <!-- Allow properties following these statements to be overridden -->
  <!-- Note that all of these don't have to exist.  They've just been defined
       incase they are used. -->
  <property file="build.properties"/>
  <property file=".ant.properties"/>
  <property file="${user.home}/.ant.properties"/>
  <property file="default.properties"/>  
  
  <!-- Location of where to put our build output -->
  <property name="tmp.dir" value="."/>

  <!-- Build directories -->
  <property name="build.dir" value="${tmp.dir}/build"/>
  <property name="build.classes.dir" value="${build.dir}/classes"/>
  <property name="docs.dir" value="${build.dir}"/>
  <property name="docs.user.dir" value="${docs.dir}/docs"/>
  <property name="docs.java.dir" value="${docs.dir}/apidocs/which"/>
  <property name="docs.printer.dir" value="${docs.user.dir}/printer"/>
  
  <!-- Source constants and directories -->
  <property name="src.dir" value="src" />
  <property name="env.subdir" value="org/apache/env" />
  <property name="env.jar.location" value="${build.dir}" />
  <property name="env.jar.name" value="which.jar" />
  <property name="env.jar" value="${env.jar.location}/${env.jar.name}" />
  
  <!-- Test results directory -->
  <property name="check.dir" value="${tmp.dir}/${project.name}/check"/>

  <!-- Build properties -->
  <property name="build.debug" value="on"/>
  <property name="build.deprecation" value="on"/>
  <property name="build.optimize" value="off"/>
  
  <!-- Document constants -->
  <property name="company.name" value="Apache Software Foundation"/>
  
  <property name="copyright.date" value="2001"/>
  <property name="copyright.message"
            value="Copyright &#169; ${copyright.date} ${company.name}. All Rights Reserved."/>

  <!-- Public Targets -->
  <target name="main"
          depends="all, check"
          description="Alias for all, check."/>
  
  <target name="all"
          depends="jar,docs,javadocs"
          description="This is the default target.  Compiles the program.">
  </target>

  <target name="compile" depends="init"
    description="Compile all classes">
   <javac srcdir="${src.dir}" destdir="${build.classes.dir}" 
       includes="${env.subdir}/*.java" />
  </target>

  <target name="jar" depends="compile"
    description="Jar all classes">
    <echo message="Jarring ${env.jar} from ${build.classes.dir}" />
    <copy todir="${build.classes.dir}">
      <fileset dir="${src.dir}" includes="**/*.properties"/>
    </copy>  

    <jar jarfile="${env.jar}" manifest="${build.dir}/manifest.which" basedir="${build.classes.dir}" />
  </target>

  <target name="install">
    <echo message="${name.which} currently doesn&apos;t support install."/>
  </target>          

  <target name="uninstall">
    <echo message="${name.which} currently doesn&apos;t support uninstall."/>
  </target>          
  
  <target name="clean"
          description="Deletes all files that are generated by the build.">
    <delete dir="${build.dir}"/>
  </target>
  
  <target name="distclean"
          depends="clean"
          description="Deletes all files that a left from clean and returns the project to its distributed state.">
  </target>
  
  <target name="docs"
          depends="javadocs, printerdocs"
          description="Generates all documentation for a project.">
  </target>
  
  <target name="javadocs"
          depends="init"
          description="Generates the JavaDocs for the project.">
    
    <mkdir dir="${docs.java.dir}"/>  
	  <javadoc packagenames="org.apache.env"
		  sourcepath="${src.dir}"
		  destdir="${docs.java.dir}"
          author="true"
          version="true"
          use="true"
		  windowtitle="${name.which} API"
		  doctitle="${name.which}"
		  bottom="${copyright.message}">
	  </javadoc>
  </target>
  
  <target name="printerdocs"
          depends="init"
          description="Generates a printer friendly version of the documentation.">
    <echo message="${name.which} currently doesn&apos;t have any user documents in a printable format."/>
  </target>
  
  <target name="dist"
          depends="all, docs"
          description="Generates all the artifacts used for a distribution.">
    <echo message="${name.which} currently doesn&apos;t support &apos;dist&apos;."/>
  </target>

  <target name="test"
          depends="check"
          description="Alias for check">
  </target>

  <target name="check"
          depends="jar"
          description="Compile and execute any tests.">
    <echo message="BEGIN Simple test: just call Which (manual verification required)."/>
    <java classname="org.apache.env.Which">
      <classpath>
        <pathelement location="${env.jar}"/>
        <pathelement path="${java.class.path}"/>
      </classpath>
    </java> 
    <echo message="END Simple test: just call Which (manual verification required)."/>
  </target>

  <!-- Internal Targets -->
  <target name="init">
    <echo message="Building ${name.which} (version: ${version}) Buildfile: $Revision$"/>
    <mkdir dir="${build.classes.dir}" />
    <mkdir dir="${docs.user.dir}" />
    <mkdir dir="${docs.java.dir}" />
    <filter token="impl.version" value="${impl.version}"/>
    <filter token="impl.name" value="${impl.name}"/>
    <copy todir="${build.dir}" file="${src.dir}/manifest.which" filtering="true"/>
  </target>

  <!-- Project specific Targets -->
  
</project>
