Added new <code>issue</code> attribute to <code><action></code> elements in <code>changes.xml</code> file. Fixes MPCHANGES-1.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@114337 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
121
changes/src/main/org/apache/maven/changes/IssueFinder.java
Normal file
121
changes/src/main/org/apache/maven/changes/IssueFinder.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package org.apache.maven.changes;
|
||||
|
||||
/* ====================================================================
|
||||
* The Apache Software License, Version 1.1
|
||||
*
|
||||
* Copyright (c) 2001 The Apache Software Foundation. All rights
|
||||
* reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. The end-user documentation included with the redistribution,
|
||||
* if any, must include the following acknowledgment:
|
||||
* "This product includes software developed by the
|
||||
* Apache Software Foundation (http://www.apache.org/)."
|
||||
* Alternately, this acknowledgment may appear in the software itself,
|
||||
* if and wherever such third-party acknowledgments normally appear.
|
||||
*
|
||||
* 4. The names "Apache" and "Apache Software Foundation" and
|
||||
* "Apache Maven" must not be used to endorse or promote products
|
||||
* derived from this software without prior written permission. For
|
||||
* written permission, please contact apache@apache.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "Apache",
|
||||
* "Apache Maven", nor may "Apache" appear in their name, without
|
||||
* prior written permission of the Apache Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
||||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
|
||||
*
|
||||
* @version $Id: IssueFinder.java,v 1.1 2003/11/15 20:13:08 vmassol Exp $
|
||||
*/
|
||||
public class IssueFinder
|
||||
{
|
||||
/**
|
||||
* @param trackerURL the issue tracker URL (this is supposed to be the
|
||||
* value of <issueTrackingUrl> found in the POM.
|
||||
* @param isue the issue reference
|
||||
* @param template the template string. Allowed template patterns are
|
||||
* <code>%URL%</code> and <code>%ISSUE%</code>. They will be
|
||||
* replaced by the base tracker URL extracted from trackerURL and
|
||||
* by the issue reference.
|
||||
* @return
|
||||
*/
|
||||
public static String getIssueURL(String trackerURL, String issue,
|
||||
String template)
|
||||
{
|
||||
// Find base URL of issue tracker
|
||||
String baseURL;
|
||||
int pos = trackerURL.lastIndexOf("/");
|
||||
if (pos > 0) {
|
||||
baseURL = trackerURL.substring(0, pos - 1);
|
||||
} else {
|
||||
throw new RuntimeException("Failed to extract tracker URL from ["
|
||||
+ trackerURL + "]");
|
||||
}
|
||||
|
||||
// Use template to construct issue URL
|
||||
String issueURL = replace(template, "%URL%", baseURL);
|
||||
issueURL = replace(issueURL, "%ISSUE%", issue);
|
||||
|
||||
return issueURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param original the original template
|
||||
* @param oldPattern the pattern to replace
|
||||
* @param newPattern the new pattern
|
||||
* @return the modified template string with patterns applied
|
||||
*/
|
||||
public static final String replace(String original, String oldPattern,
|
||||
String newPattern)
|
||||
{
|
||||
int index, oldIndex;
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
||||
if((index = original.indexOf(oldPattern)) != -1) {
|
||||
oldIndex = 0;
|
||||
while((index = original.indexOf(oldPattern, oldIndex)) != -1) {
|
||||
buffer.append(original.substring(oldIndex, index));
|
||||
buffer.append(newPattern);
|
||||
oldIndex = index + oldPattern.length();
|
||||
}
|
||||
buffer.append(original.substring(oldIndex));
|
||||
original = buffer.toString();
|
||||
}
|
||||
return original;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,9 +51,18 @@
|
||||
<jsl:template match="action">
|
||||
<j:set var="type"><x:expr select="@type"/></j:set>
|
||||
<j:set var="dev"><x:expr select="@dev"/></j:set>
|
||||
<j:set var="issue"><x:expr select="@issue"/></j:set>
|
||||
<tr>
|
||||
<td><img src="images/${type}.gif" alt="${type}"/></td>
|
||||
<td><jsl:applyTemplates trim="false"/></td>
|
||||
<td>
|
||||
<jsl:applyTemplates trim="false"/>
|
||||
<j:if test="${issue != null}">
|
||||
<j:useBean var="finder" class="org.apache.maven.changes.IssueFinder"/>
|
||||
<j:set var="template" value="${maven.changes.issue.template}"/>
|
||||
<j:set var="trackerURL" value="${pom.issueTrackingUrl}"/>
|
||||
Fixes <a href="${finder.getIssueURL(trackerURL,issue,template)}">${issue}</a>
|
||||
</j:if>
|
||||
</td>
|
||||
<td><a href="team-list.html#${dev}">${dev}</a></td>
|
||||
</tr>
|
||||
</jsl:template>
|
||||
|
||||
Reference in New Issue
Block a user