<?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:changelog="changelog"
  xmlns:maven="jelly:maven"
  xmlns:util="jelly:util"
  xmlns:doc="doc">

  <goal name="maven-developer-activity-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="Developer Activity" 
        pluginName="maven-developer-activity-plugin"
        link="developer-activity-report"
        description="Report on the amount of developer activity."/>
    </j:if>
  </goal>
  
  <goal name="maven-developer-activity-plugin:deregister">
    <doc:deregisterReport name="Developer Activity"/>
  </goal>

  <!-- ================================================================== -->
  <!-- D E V E L O P E R  A C T I V I T Y  R E P O R T                    -->
  <!-- ================================================================== -->

  <goal name="maven-developer-activity-plugin:report"
        description="Generate developer and file activity reports">

    <j:if test="${context.getVariable('maven.mode.online') == null}">
      <j:set var="maven.mode.online" value="true" />
    </j:if>

    <maven:pluginVar var="factory" plugin="maven-changelog-plugin" property="maven.changelog.factory" />

    <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 developer activity report</ant:echo>
          
          <!--
           |
           | Now we only want to generate the change log if it hasn't
           | already been generated.
           |
          -->
          
          <util:available file="${maven.build.dir}/changelog.xml">
            <j:set var="changelogPresent" value="true"/>
          </util:available>
          
          <j:if test="${changelogPresent != 'true'}">
            <changelog:changelog
              basedir="${maven.changelog.basedir}"
              developers="${pom.developers}"
              factory="${factory}"
              output="${maven.build.dir}/changelog.xml"
              outputEncoding="${maven.docs.outputencoding}"
              range="${maven.activitylog.range}"
              repositoryConnection="${_connection}"
              dateFormat="${maven.changelog.dateformat}"
            />
          </j:if>

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

        </j:if>
      </j:when>

      <j:otherwise>
        <ant:echo>The Activity report is only available in online mode.</ant:echo>
      </j:otherwise>
    </j:choose>

  </goal>

</project>
