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

  <goal name="maven-changelog-plugin:register">
    <j:if test="${context.getVariable('maven.mode.online') == null}">
      <j:set var="maven.mode.online" value="true" />
    </j:if>
    <j:if test="${maven.mode.online}">
      <doc:registerReport 
        name="Change Log" 
        pluginName="maven-changelog-plugin"
        link="changelog-report"
        description="Report on the source control changelog."/>
    </j:if>
  </goal>
  
  <goal name="maven-changelog-plugin:deregister">
    <doc:deregisterReport name="Change Log"/>
  </goal>

  <define:taglib uri="changelog">
    <define:jellybean
      name="changelog"
      className="org.apache.maven.changelog.ChangeLog"
      method="doExecute"
      />
  </define:taglib>

  <!-- ================================================================== -->
  <!-- C H A N G E  L O G  R E P O R T                                    -->
  <!-- ================================================================== -->

  <goal
    name="maven-changelog-plugin:report"
    description="Generate a changelog report">

    <j:if test="${context.getVariable('maven.mode.online') == null}">
      <j:set var="maven.mode.online" value="true"/>
    </j:if>
    <j:choose>
      <j:when test="${maven.mode.online}">
        <j:set var="_connection">${pom.repository.connection}</j:set>
        <j:if test="${empty(_connection)}">
          <j:set var="_connection">${pom.repository.developerConnection}</j:set>
        </j:if>
        <j:if test="${!empty(_connection)}">
          <ant:echo>Generating the changelog report</ant:echo>

          <changelog:changelog
            basedir="${maven.changelog.basedir}"
            developers="${pom.developers}"
            factory="${maven.changelog.factory}"
            output="${maven.build.dir}/changelog.xml"
            outputEncoding="${maven.docs.outputencoding}"
            range="${maven.changelog.range}"
            repositoryConnection="${_connection}"
            dateFormat="${maven.changelog.dateformat}"
            />

          <doc:jsl
            input="${maven.build.dir}/changelog.xml"
            output="changelog-report.xml"
            stylesheet="${plugin.resources}/changelog.jsl"
            encoding="${maven.docs.outputencoding}"
            outputMode="xml"
            prettyPrint="true"
            />

        </j:if>
      </j:when>
      <j:otherwise>
        <ant:echo>The Changelog is available in the online mode only.</ant:echo>
      </j:otherwise>
    </j:choose>

  </goal>
  
  <goal name="changelog:create-cvspass">
    <maven:paramCheck value="${password}" fail="true">
You must provide a password to set for the cvs repository.
Please run the goal again using:
maven -Dpassword=XXXXXX changelog:create-cvspass</maven:paramCheck>
    <echo>Setting password for ${pom.repository.cvsRoot}</echo>
    <cvspass cvsroot="${pom.repository.cvsRoot}" password="${password}"/>
  </goal>
  
</project>
