<?xml version="1.0"?>

<project default="site" basedir="." name="Forrest Ant proxy targets">

  <description>
    Proxy Forrest targets that run the customized Ant provided with Forrest,
    rather than using the invoker's version.

    The 'validate' target in forrest.build.xml requires a patched Ant 1.6 to
    run.  Thus if forrest.build.xml is invoked from a user's script, it will
    fail.  The solution is to invoke this script's proxy targets, eg:

    <![CDATA[
    <target name="site" description="Build a static website">
      <ant antfile="${forrest.home}/forrest.antproxy.xml" target="site"/>
    </target>
    ]]>
  </description>

  <property name="build.sysclasspath" value="ignore"/>

  <target name="validate" description="Validates XML doc files">
    <antcall target="forrest"><param name="target" value="validate"/></antcall>
  </target>
  <target name="webapp" description="Generates an unpacked webapp">
    <antcall target="forrest"><param name="target" value="webapp"/></antcall>
  </target>
  <target name="war" description="Generates a packaged .war webapp">
    <antcall target="forrest"><param name="target" value="war"/></antcall>
  </target>
  <target name="site" description="Generates static HTML">
    <antcall target="forrest"><param name="target" value="site"/></antcall>
  </target>

  <path id="forrest-classpath">
    <fileset dir="${forrest.home}">
      <include name="ant/lib/*.jar"/>
      <include name="lib/endorsed/*.jar"/>
    </fileset>
    <pathelement location="${java.home}/../lib/tools.jar"/>
  </path>

  <target name="forrest">
    <property name="project.home" location="."/>
    <java classname="org.apache.tools.ant.Main" fork="true" failonerror="true">
      <classpath refid="forrest-classpath"/>
      <jvmarg value="-Dforrest.home=${forrest.home}"/>
      <jvmarg value="-Dbasedir=${basedir}"/>
      <jvmarg value="-Dproject.home=${project.home}"/>
      <jvmarg value="-Djava.endorsed.dirs=${forrest.home}/lib/endorsed${path.separator}${java.endorsed.dirs}"/>
      <arg line="-f '${forrest.home}/forrest.build.xml' -emacs ${target}"/>
    </java>
  </target>


</project>
