<!--
Copyright 2001-2006 The Apache Software Foundation
Licensed 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="site" default="docs" basedir=".">

   <!-- Initialization properties -->
   <property name="project.name"   value="site"/>

   <!-- The source directory for our XML source documents which are
    to be sytlized and transformed into XHTML. -->
   <property name="docs.src" value="xdocs"/>

   <!-- The destination directory for content generated from our XML
    sources. -->
   <property name="docs.dest" value="docs"/>

   <property name="texen.work" value="target/texen"/>
   <property name="texen.src" value="xdocs/stylesheets/texen"/>

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

   <target name="prepare-texen">
      <available classname="org.apache.velocity.texen.ant.TexenTask" 
            property="TexenTask.present">
         <classpath refid="classpath"/>
      </available>
   </target>

   <target depends="prepare-texen" name="prepare-error-texen" unless="TexenTask.present">
      <echo>
           TexenTask is not present! Please check to make sure that 
            velocity.jar is in your classpath.
        </echo>
   </target>

   <target name='generate-site-map' depends='prepare-texen' if='TexenTask.present'>
      <mkdir dir='${texen.work}'/>
      <taskdef 
            name="texen" 
            classname="org.apache.velocity.texen.ant.TexenTask" 
            classpathref='classpath' />
      <!-- Use XSLT to extract indexes from development documents -->
      <style 
            processor="trax"
            basedir='${docs.src}/dev' 
            destdir='${texen.work}' 
            extension='.xml' 
            style='${texen.src}/index.xsl'>
         <exclude name='navigation.xml' />
         <exclude name='sitemap.xml' />
                        <exclude name='index.xml' />
         <include name='*.xml' />
      </style>

      <!-- Use Texen to combine indexes into final document -->
      <texen 
            controlTemplate='control.vsl' 
            outputDirectory='${docs.src}/dev' 
            templatePath='${texen.src}' 
            outputFile='../../${texen.work}/generation.report' />
   </target>

   <target name="prepare">
      <available classname="org.apache.velocity.anakia.AnakiaTask" property="AnakiaTask.present">
         <classpath refid="classpath"/>
      </available>
   </target>

   <target depends="prepare" name="prepare-error" unless="AnakiaTask.present">
      <echo>
            AnakiaTask is not present! Please check to make sure that 
            velocity.jar is in your classpath.
        </echo>
   </target>

   <target name="docs" depends="prepare-error, generate-site-map" if="AnakiaTask.present">
      <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
         <classpath refid="classpath"/>
      </taskdef>
      <anakia basedir="${docs.src}" destdir="${docs.dest}/"
             extension=".html" style="./site.vsl"
             projectFile="stylesheets/project.xml"
             excludes="**/stylesheets/** empty.xml"
             includes="**/*.xml"
             lastModifiedCheck="true"
             templatePath="${docs.src}/stylesheets"
        >
      </anakia>

      <copy todir="${docs.dest}/" filtering="no">
         <fileset dir="${docs.src}/">
            <!-- 
               Ignore the Anakia style sheet used for processing
                   of the xdocs, and the unprocessed xdocs themselves,
                   but copy all other content to the directory which is
                   checked out on the server. 
                -->
            <exclude name="**/*.xml"/>
            <exclude name="**/stylesheets/**"/>

            <!-- Editor-specific ignores. -->
            <exclude name="**/*~"/>
            <exclude name="**/.#*"/>
         </fileset>
      </copy>

   </target>
</project>

