<?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="Harmony" default="site" basedir=".">

  <property file="${user.home}/.ant.properties" />
  <property file="${user.home}/build.properties" />
  <property file=".ant.properties" />

  <property name="ant.home" value="."/>
  <property name="debug" value="on"/>
  <property name="optimize" value="on"/>
  <property name="deprecation" value="off"/>

  <property name="docs.dest" value="docs"/>
  <property name="docs.src" value="xdocs"/>

  <!-- Build classpath -->
  <path id="classpath">
    <fileset dir="./lib">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <!-- =================================================================== -->
  <!-- prints the environment                                              -->
  <!-- =================================================================== -->
  <target name="env">
    
    <echo message="java.home = ${java.home}"/>
    <echo message="user.home = ${user.home}"/>
    <echo message="java.class.path = ${java.class.path}"/>
    <echo message=""/>
  
  </target>

  <!-- =================================================================== -->
  <!-- Make HTML version of Harmony site                        -->
  <!-- =================================================================== -->

  <target name="site" 
          description="generates the HTML documentation"
          depends="check-jre">
      <taskdef name="anakia"
          classname="org.apache.velocity.anakia.AnakiaTask">
          
          <classpath>
             <path refid="classpath"/>
          </classpath>

      </taskdef>

      <echo>
       #######################################################
       #
       #  Now using Anakia to transform our XML documentation
       #  to HTML.
       #
       #######################################################
      </echo>

      <anakia basedir="${docs.src}" destdir="${docs.dest}/"
           extension=".html" style="./site.vsl"
           projectFile="stylesheets/project.xml"
           excludes="**/stylesheets/** empty.xml **/*.ru.xml"
           includes="**/*.xml"
           lastModifiedCheck="true"
           templatePath="xdocs/stylesheets">
      </anakia>

      <anakia basedir="${docs.src}" destdir="${docs.dest}/"
           extension=".html" style="./site.vsl"
           projectFile="stylesheets/project.ru.xml"
           excludes="**/stylesheets/** empty.xml"
           includes="**/*.ru.xml"
           lastModifiedCheck="true"
           templatePath="xdocs/stylesheets">
      </anakia>

      <!-- top level images -->

      <copy todir="${docs.dest}/images" filtering="no">
          <fileset dir="${docs.src}/images">
              <include name="**/*.gif"/>
              <include name="**/*.jpeg"/>
              <include name="**/*.jpg"/>
              <include name="**/*.png"/>
          </fileset>
      </copy>

      <!-- images for drlvm sub component -->
      <copy todir="${docs.dest}/subcomponents/drlvm/images" filtering="no">
          <fileset dir="${docs.src}/subcomponents/drlvm/images">
              <include name="**/*.gif"/>
              <include name="**/*.jpeg"/>
              <include name="**/*.jpg"/>
              <include name="**/*.png"/>
          </fileset>
      </copy>

      <!-- images for classlibrary sub component -->
      <copy todir="${docs.dest}/subcomponents/classlibrary/images" filtering="no">
          <fileset dir="${docs.src}/subcomponents/classlibrary/images">
              <include name="**/*.gif"/>
              <include name="**/*.jpeg"/>
              <include name="**/*.jpg"/>
              <include name="**/*.png"/>
          </fileset>
      </copy>

      <copy todir="${docs.dest}/" filtering="no">
           <fileset dir="${docs.src}">
              <include name="**/*.txt"/>
              <include name="**/*.cgi"/>
           </fileset>
      </copy>

      <copy file="${docs.src}/stylesheets/site.css" todir="${docs.dest}/css/"/>
      <copy file="${docs.src}/stylesheets/screen.css" todir="${docs.dest}/css/"/>
      <copy file="${docs.src}/stylesheets/print.css" todir="${docs.dest}/css/"/>
      <copy file="${docs.src}/.htaccess" todir="${docs.dest}/"/>

      <fixcrlf srcdir="${docs.dest}" includes="**/*.html" />

  </target>
    

  <target name="check-jre">
      <fail message="You need to generate the site using Harmony">
          <condition>
              <not>
                  <equals arg1="Apache Harmony" arg2="${java.runtime.name}"/>
              </not>
          </condition>
      </fail>
  </target>

</project>



