You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by vm...@apache.org on 2003/11/15 21:13:09 UTC

cvs commit: maven-plugins/changes/src/plugin-resources changes.jsl

vmassol     2003/11/15 12:13:09

  Modified:    changes  plugin.properties
               changes/xdocs properties.xml changes.xml
               changes/src/plugin-resources changes.jsl
  Added:       changes/src/main/org/apache/maven/changes IssueFinder.java
  Log:
  Added new <code>issue</code> attribute to <code>&lt;action&gt;</code> elements in <code>changes.xml</code> file. Fixes MPCHANGES-1.
  
  Revision  Changes    Path
  1.1                  maven-plugins/changes/src/main/org/apache/maven/changes/IssueFinder.java
  
  Index: IssueFinder.java
  ===================================================================
  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 &lt;issueTrackingUrl&gt; 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;
      }
  
  }
  
  
  1.3       +9 -0      maven-plugins/changes/plugin.properties
  
  Index: plugin.properties
  ===================================================================
  RCS file: /home/cvs/maven-plugins/changes/plugin.properties,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- plugin.properties	5 Jun 2003 20:34:13 -0000	1.2
  +++ plugin.properties	15 Nov 2003 20:13:08 -0000	1.3
  @@ -3,3 +3,12 @@
   # -------------------------------------------------------------------
   # changes plugin.
   # -------------------------------------------------------------------
  +
  +# Template that is used to discover the URL to use to display a bug report.
  +# There are 2 template tokens you can use:
  +#  %URL%: this is computed by getting the <issueTrackingUrl> value from the
  +#         POM, and removing the context path.
  +#  %ISSUE% : this is the issue number.
  +# The default template below is the one for the JIRA bug tracker.
  +
  +maven.changes.issue.template = %URL%/ViewIssue.jspa?key=%ISSUE%
  
  
  
  1.3       +20 -5     maven-plugins/changes/xdocs/properties.xml
  
  Index: properties.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/changes/xdocs/properties.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- properties.xml	5 Jun 2003 20:34:13 -0000	1.2
  +++ properties.xml	15 Nov 2003 20:13:08 -0000	1.3
  @@ -2,15 +2,30 @@
   <document>
   
     <properties>
  -    <title>Changes Properties</title>
  +    <title>Changes plugin properties</title>
       <author email="vmassol@apache.org">Vincent Massol</author>
     </properties>
   
     <body>
  -    <section name="Changes Properties">
  -      <p>
  -        There are no properties for this plugin.
  -      </p>
  +    <section name="Changes plugin properties">
  +      <table>
  +        <tr><th>Property</th><th>Optional?</th><th>Description</th><th>Default</th></tr>
  +        <tr>
  +          <td>maven.changes.issue.template</td>
  +          <td>Yes</td>
  +          <td>
  +            Template string that is used to discover the URL to use to display 
  +            a bug report. There are 2 template tokens you can use.
  +            <code>%URL%</code>: this is computed by getting the 
  +            <code>&lt;issueTrackingUrl&gt;</code> value from the POM, and 
  +            removing the context path. <code>%ISSUE%</code> : this is the issue
  +            number. The default template is the one for the JIRA bug tracker.
  +          </td>
  +          <td>
  +            <code>%URL%/ViewIssue.jspa?key=%ISSUE%</code>
  +          </td>
  +        </tr>
  +      </table>
       </section>
     </body>
   </document>
  
  
  
  1.10      +6 -4      maven-plugins/changes/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/maven-plugins/changes/xdocs/changes.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- changes.xml	15 Nov 2003 19:10:47 -0000	1.9
  +++ changes.xml	15 Nov 2003 20:13:08 -0000	1.10
  @@ -8,8 +8,11 @@
     <body>
   
       <release version="1.3" date="in CVS">
  -      <action dev="vmassol" type="fix">
  -        <a href="http://jira.codehaus.org/secure/ViewIssue.jspa?key=MPCHANGES-3">MPCHANGES-3</a>.
  +      <action dev="vmassol" type="fix" issue="MPCHANGES-1">
  +        Added new <code>issue</code> attribute to <code>&lt;action&gt;</code>
  +        elements in <code>changes.xml</code> file.
  +      </action>          
  +      <action dev="vmassol" type="fix" issue="MPCHANGES-3">
           HTML tags entered inside <code>&lt;action&gt;</code> tags now show up 
           in the generated report.
         </action>          
  @@ -22,8 +25,7 @@
         <action dev="dion" type="update">
           Update to use maven.docs.*/maven.gen.docs
         </action>
  -      <action dev="evenisse" type="add">
  -        <a href="http://jira.codehaus.org/ViewIssue.jspa?key=MAVEN-587">Maven-587</a>.
  +      <action dev="evenisse" type="add" issue="MPCHANGES-4">
           Add index table of release.
         </action>          
         <action dev="evenisse" type="fix">
  
  
  
  1.7       +10 -1     maven-plugins/changes/src/plugin-resources/changes.jsl
  
  Index: changes.jsl
  ===================================================================
  RCS file: /home/cvs/maven-plugins/changes/src/plugin-resources/changes.jsl,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- changes.jsl	15 Nov 2003 19:10:47 -0000	1.6
  +++ changes.jsl	15 Nov 2003 20:13:09 -0000	1.7
  @@ -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>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org