<?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:define="jelly:define"
  xmlns:doc="doc"
  xmlns:j="jelly:core"  
  xmlns:jxr="jxr"
  xmlns:maven="jelly:maven"
  xmlns:util="jelly:util">

  <define:taglib uri="jxr">
    <define:jellybean
      name="jxr"
      className="org.apache.maven.jxr.JxrBean"
      method="xref"
      />
  </define:taglib>

  <goal name="maven-jxr-plugin:register">
    <j:if test="${sourcesPresent}">
      <doc:registerReport 
        name="Source Xref" 
        pluginName="maven-jxr-plugin" 
        link="xref/index"
        description="A set of browsable cross-referenced sources."/>
      <j:if test="${unitTestSourcesPresent}">
      <doc:registerReport 
          name="Test Xref" 
          pluginName="maven-jxr-plugin" 
          link="xref-test/index"
          description="A set of browsable cross-referenced test sources."/>
      </j:if>
    </j:if>
  </goal>
  
  <goal name="maven-jxr-plugin:deregister">
    <doc:deregisterReport name="Source Xref"/>
    <doc:deregisterReport name="Test Xref"/>
  </goal>

  <!-- ================================================================== -->
  <!-- C R O S S  R E F E R E N C E  S O U R C E S                        -->
  <!-- ================================================================== -->

  <!-- Should we deprecate it to use only 'jxr' ? -->
  <goal
    name="maven-jxr-plugin:report"
    description="Generate HTML cross reference sources">

    <j:if test="${sourcesPresent == 'true'}">

      <ant:mkdir dir="${maven.jxr.destdir}"/>

      <!-- If the 'startDir' attribute changes we need to update
           CodeTransform.java in o.a.m.jxr, this will be fixed. -->

      <ant:echo>${maven.sourcesPresent}</ant:echo>

      <maven:pluginVar var="javadocDestdir" plugin='maven-javadoc-plugin' property='maven.javadoc.destdir'/>

      <j:set var="copyright"
        value="Copyright &amp;copy; ${year} ${pom.organization.name}. All Rights Reserved." />

      <j:set var="title" value="${pom.name} ${pom.currentVersion} Reference" />

      <ant:copy file="${maven.jxr.stylesheet}"
        tofile="${maven.jxr.destdir}/stylesheet.css"/>
        
      <jxr:jxr
        sourceDir="${pom.build.sourceDirectory}"
        destDir="${maven.jxr.destdir}"
        templateDir="${maven.jxr.templateDir}"
        javadocDir="${javadocDestdir}"
        windowTitle="${title}"
        docTitle="${title}"
        bottom="${copyright}">
      </jxr:jxr>

      <j:if test="${unitTestSourcesPresent == 'true'}">
        <ant:mkdir dir="${maven.jxr.destdir.test}"/>
    
        <ant:copy file="${maven.jxr.stylesheet}"
          tofile="${maven.jxr.destdir.test}/stylesheet.css"/>

        <jxr:jxr
          sourceDir="${pom.build.unitTestSourceDirectory}"
          destDir="${maven.jxr.destdir.test}"
          templateDir="${maven.jxr.templateDir}"
          javadocDir="${null}"
          windowTitle="${title}"
          docTitle="${title}"
          bottom="${copyright}">
        </jxr:jxr>

      </j:if>

    </j:if>
    
  </goal>

</project>
