2007-04-23 21:28:38 +00:00

281 lines
12 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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:multiproject="multiproject"
xmlns:j="jelly:core"
xmlns:ant="jelly:ant"
xmlns:define="jelly:define"
xmlns:util="jelly:util"
xmlns:m="jelly:maven"
xmlns:x="jelly:xml"
xmlns:doc="doc">
<!--
========================================================================
Initialize Multichanges plugin data.
========================================================================
-->
<goal name="multichanges:init">
<j:if test="${!multichanges_init_already_executed}">
<!-- Default reactor properties from the Multiproject plug-in -->
<!-- Make sure the multiproject plugin is loaded -->
<m:set plugin="maven-multiproject-plugin" property="foo" value="bar"/>
<m:get var="mBasedir" property="maven.multiproject.basedir" plugin="maven-multiproject-plugin"/>
<m:property var="dBasedir" name="maven.multichanges.basedir" defaultValue="${mBasedir}"/>
<m:get var="mIncludes" property="maven.multiproject.includes" plugin="maven-multiproject-plugin"/>
<m:property var="dIncludes" name="maven.multichanges.includes" defaultValue="${mIncludes}"/>
<m:get var="mExcludes" property="maven.multiproject.excludes" plugin="maven-multiproject-plugin"/>
<m:property var="dExcludes" name="maven.multichanges.excludes" defaultValue="${mExcludes}"/>
<m:get var="mIgnoreFailures" property="maven.multiproject.ignoreFailures" plugin="maven-multiproject-plugin"/>
<m:property var="dIgnoreFailures" name="maven.multichanges.ignoreFailures" defaultValue="${mIgnoreFailures}"/>
<ant:dirname property="dataReportDir" file="${maven.multichanges.data}"/>
<ant:mkdir dir="${dataReportDir}"/>
<!-- Copy the images -->
<mkdir dir="${maven.docs.dest}/images"/>
<copy todir="${maven.docs.dest}/images">
<fileset dir="${plugin.resources}/images"/>
</copy>
<j:set var="multichanges_init_already_executed" value="true"/>
</j:if>
</goal>
<!--
========================================================================
Generate a multiproject release report, providing a unified view of
the latest release of projects.
========================================================================
-->
<goal name="multichanges:report" prereqs="multichanges:generates-releases-report,multichanges:generates-next-releases-report,multichanges:generates-releases-rss"/>
<goal name="multichanges:generates-releases-file" prereqs="multichanges:init">
<j:if test="${!multichanges_generates_releases_file_already_executed}">
<j:useBean var="dateFormatter" class="org.apache.maven.plugin.multichanges.util.DateFormatter"/>
<!-- Gather project list using the maven reactor -->
<m:reactor
basedir="${dBasedir}"
banner="Gathering project list"
includes="${dIncludes}"
excludes="${dExcludes}"
postProcessing="true"
collectOnly="true"
ignoreFailures="${dIgnoreFailures}"/>
<j:file name="${maven.multichanges.data}" prettyPrint="true" xmlns="release">
<releases>
<j:forEach var="reactorProject" items="${reactorProjects}">
<x:element name="project">
<x:attribute name="name">
${reactorProject.name}
</x:attribute>
<x:attribute name="groupId">
${reactorProject.groupId}
</x:attribute>
<x:attribute name="artifactId">
${reactorProject.artifactId}
</x:attribute>
<x:attribute name="url">
${reactorProject.url}
</x:attribute>
<x:attribute name="issueTrackingUrl">
${reactorProject.issueTrackingUrl}
</x:attribute>
<x:attribute name="issueTrackingTemplate">
${reactorProject.context.getVariable('maven.changes.issue.template')}
</x:attribute>
<util:file var="changesAsFile"
name="${reactorProject.context.getVariable('maven.docs.src')}/changes.xml"/>
<j:choose>
<!-- If there's a changes.xml file -->
<j:when test="${changesAsFile.exists()}">
<!-- We parse it -->
<x:parse var="doc" xml="${changesAsFile}"/>
<x:set var="firstRelease" select="$doc//release[1]"/>
<j:choose>
<!-- If in this file there is at least one release entry
and this release has at least one action-->
<j:when test="${firstRelease!=null and !firstRelease.isEmpty()}">
<j:choose>
<!-- If this is the last release (with a release date) ? -->
<j:when test="${dateFormatter.isChangesDate(firstRelease.get(0).attributeValue('date'))}">
<x:element name="last">
<x:copyOf select="$doc//release[1]"/>
</x:element>
<!-- We have no information about the next release -->
<x:element name="next">
<x:element name="release">
<j:choose>
<!-- If the POM version wasn't modified since the last release -->
<j:when test="${reactorProject.currentVersion.equals(firstRelease.get(0).attributeValue('version'))}">
<x:attribute name="version">No future version planned</x:attribute>
</j:when>
<j:otherwise>
<x:attribute name="version">${reactorProject.currentVersion} but no changes registred actually.</x:attribute>
</j:otherwise>
</j:choose>
<x:attribute name="date">Not scheduled</x:attribute>
</x:element>
</x:element>
</j:when>
<!-- Otherwise this is for a future release -->
<j:otherwise>
<x:element name="next">
<x:copyOf select="$doc//release[1]"/>
</x:element>
<x:set var="secondRelease" select="$doc//release[2]"/>
<j:choose>
<!-- If there is another release and it's the last release -->
<j:when test="${secondRelease!=null and !secondRelease.isEmpty()}">
<x:element name="last">
<x:copyOf select="$doc//release[2]"/>
</x:element>
</j:when>
<!-- This was never released -->
<j:otherwise>
<x:element name="last">
<x:element name="release">
<x:attribute name="version">Never released</x:attribute>
<x:attribute name="date">Never released</x:attribute>
</x:element>
</x:element>
</j:otherwise>
</j:choose>
</j:otherwise>
</j:choose>
</j:when>
<!-- There's no releases entries in the changes file -->
<j:otherwise>
<!-- We have no information about the last release -->
<x:element name="last">
<x:element name="release">
<x:attribute name="version">No information available</x:attribute>
<x:attribute name="date">No information available</x:attribute>
</x:element>
</x:element>
<!-- We have no information about the next release -->
<x:element name="next">
<x:element name="release">
<x:attribute name="version">${reactorProject.currentVersion} but no changes registred actually.</x:attribute>
<x:attribute name="date">No information available</x:attribute>
</x:element>
</x:element>
</j:otherwise>
</j:choose>
</j:when>
<!-- There's no changes file -->
<j:otherwise>
<!-- We have no information about the last release -->
<x:element name="last">
<x:element name="release">
<x:attribute name="version">No information available</x:attribute>
<x:attribute name="date">No information available</x:attribute>
</x:element>
</x:element>
<!-- We have no information about the next release -->
<x:element name="next">
<x:element name="release">
<x:attribute name="version">${reactorProject.currentVersion}</x:attribute>
<x:attribute name="date">No information available</x:attribute>
</x:element>
</x:element>
</j:otherwise>
</j:choose>
</x:element>
</j:forEach>
</releases>
</j:file>
<j:set var="multichanges_generates_releases_file_already_executed" value="true"/>
</j:if>
</goal>
<goal name="multichanges:generates-releases-report" prereqs="multichanges:generates-releases-file">
<j:if test="${!multichanges_generates_releases_already_executed}">
<doc:jsl
input="${maven.multichanges.data}"
output="${maven.multichanges.report}.xml"
stylesheet="${plugin.resources}/releases.jsl"
outputMode="xml"
prettyPrint="true"/>
<j:set var="multichanges_generates_releases_already_executed" value="true"/>
</j:if>
</goal>
<goal name="multichanges:generates-next-releases-report" prereqs="multichanges:generates-releases-file">
<j:if test="${!multichanges_generates_next_releases_already_executed}">
<doc:jsl
input="${maven.multichanges.data}"
output="${maven.multichanges.report}-next.xml"
stylesheet="${plugin.resources}/next-releases.jsl"
outputMode="xml"
prettyPrint="true"/>
<j:set var="multichanges_generates_next_releases_already_executed" value="true"/>
</j:if>
</goal>
<goal name="multichanges:generates-releases-rss" prereqs="multichanges:generates-releases-file">
<j:if test="${!multichanges_generates_releases_rss_already_executed}">
<tstamp>
<format property="currentDate" pattern="EEE, dd MMM yyyy HH:mm:ss Z" locale="en"/>
</tstamp>
<tstamp>
<format property="currentYear" pattern="yyyy"/>
</tstamp>
<!-- Generate a RSS feed of the changes -->
<doc:jsl
input="${maven.multichanges.data}"
output="releases.rss"
stylesheet="${plugin.resources}/releases2rss.jsl"
encoding="${maven.docs.outputencoding}"
outputMode="xml"
prettyPrint="false"/>
<j:set var="multichanges_generates_releases_rss_already_executed" value="true"/>
</j:if>
</goal>
<!--
========================================================================
Register the report to the xdoc plugin.
========================================================================
-->
<goal name="maven-multichanges-plugin:register">
<doc:registerReport
name="Latest releases"
pluginName="multichanges"
link="${maven.multichanges.report}"
description="Report on latest projects releases."/>
<doc:registerReport
name="Next releases"
pluginName="multichanges"
link="${maven.multichanges.report}-next"
description="Report on next projects releases."/>
</goal>
<!--
========================================================================
Unregister the report to the xdoc plugin.
========================================================================
-->
<goal name="maven-multichanges-plugin:deregister">
<doc:deregisterReport name="Latest releases"/>
<doc:deregisterReport name="Next releases"/>
</goal>
</project>