<?xml version="1.0"?>
<!-- 
/*
 * Copyright 2001-2004 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
  xmlns:ant="jelly:ant"
  xmlns:j="jelly:core"
  xmlns:doc="doc">

  <goal name="maven-jellydoc-plugin:register">
    <j:if test="${sourcesPresent}">
      <doc:registerReport
        name="Jelly Tag Documentation"
        pluginName="maven-jellydoc-plugin"
        link="tags"
        description="Jelly Tag Documentation."/>
    </j:if>
  </goal>
  
  <goal name="maven-jellydoc-plugin:deregister">
    <doc:deregisterReport name="Jelly Tag Documentation"/>
  </goal>

  <goal name="maven-jellydoc-plugin:report"
    prereqs="jellydoc"
    description="Generates the tag documentation"/>

  <!-- ================================================================== -->
  <!-- GENERATE THE XML DOCUMENTATION                                     -->
  <!-- ================================================================== -->
  <goal name="jellydoc" prereqs="jellydoc:doclet"
    description="Generates the tag documentation">

    <ant:mkdir dir="${genDocs}"/>

    <j:file name="${genDocs}/tags.xml">
      <j:include file="${plugin.resources}/${plugin.artifactId}.jelly"/>
    </j:file>
  </goal>

  <!-- runs the Tag doclet -->
  <goal name="jellydoc:doclet" prereqs="jellydoc:init"
    description="A doclet which outputs all the Jelly tag related metadata as XML">

    <j:if test="${context.getVariable('maven.jellydoc.packages') == null}">
      <j:set var="maven.jellydoc.packages" value="${pom.package}.*"/>
    </j:if>

    <ant:echo>Generating jellydoc for packages ${maven.jellydoc.packages}</ant:echo>

    <!-- the doclet dumps taglib.xml into ${user.dir}/target -->
    <ant:mkdir dir="${maven.build.dir}"/>

    <ant:echo>Source directory is ${pom.build.sourceDirectory}</ant:echo>

    <ant:javadoc
      sourcepath="${pom.build.sourceDirectory}"
      packagenames="${maven.jellydoc.packages}"
      classpathref="doclet.classpath">
        <doclet name="org.apache.maven.jellydoc.TagXMLDoclet"
          pathref="doclet.classpath">
            <param name="-d" value="${maven.build.dir}"/>
            <param name="-encoding" value="${maven.docs.outputencoding}"/>
        </doclet>
    </ant:javadoc>
  </goal>

  <!-- runs the XML doclet -->
  <goal name="jellydoc:xml-doclet" prereqs="jellydoc:init"
    description="Creates an XML representation of the doclet information">

    <ant:javadoc
      sourcepath="${pom.build.sourceDirectory}"
      packagenames="${pom.package}.*"
      classpathref="doclet.classpath">
        <doclet name="org.apache.maven.jellydoc.XMLDoclet"
          pathref="doclet.classpath">
            <param name="-d" value="${maven.build.dir}"/>
            <param name="-encoding" value="${maven.docs.outputencoding}"/>
        </doclet>
    </ant:javadoc>

  </goal>


  <!-- sets the classpath used for doclet invocations -->
  <goal name="jellydoc:init">

    <j:set var="genDocs" value="${maven.gen.docs}"/>

    <!-- just in case this is ran before a compile -->
    <ant:mkdir dir="${genDocs}"/>

    <ant:path id="doclet.classpath">
      <ant:path refid="maven.dependency.classpath"/>
      <ant:pathelement path="${plugin.dir}"/>
      <ant:pathelement path="${plugin.getDependencyPath('javadoc')}"/>
      <ant:pathelement path="${plugin.getDependencyPath('nekohtml')}"/>
      <ant:pathelement path="${plugin.getDependencyPath('dom4j')}"/>
      <ant:pathelement path="${plugin.getDependencyPath('xerces')}"/>
      <ant:pathelement path="${plugin.getDependencyPath('xml-apis')}"/>
      <ant:pathelement path="${plugin.getDependencyPath('commons-jelly')}"/>
    </ant:path>
  </goal>

</project>
