You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2009/07/26 20:00:18 UTC

svn commit: r797966 - in /maven/plugins/trunk/maven-changes-plugin/src: it/report-changes-system-noissuemanagement/ it/report-changes-system-noissuemanagement/src/ it/report-changes-system-noissuemanagement/src/changes/ main/java/org/apache/maven/plugi...

Author: olamy
Date: Sun Jul 26 18:00:17 2009
New Revision: 797966

URL: http://svn.apache.org/viewvc?rev=797966&view=rev
Log:
[MCHANGES-166] Problem with issueLinkTemplatePerSystem
Submitted by Karl Heinz Marbaise
null

Added:
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml   (with props)
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml   (with props)
    maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh   (with props)
Modified:
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java

Added: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml?rev=797966&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml (added)
+++ maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml Sun Jul 26 18:00:17 2009
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.maven.plugins</groupId>
+  <artifactId>maven-changes-plugin-test</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>jar</packaging>
+  <description>Test report without issueManagement entry.</description>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <properties>
+    <changesPluginVersion>@pom.version@</changesPluginVersion>
+  </properties>
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-changes-plugin</artifactId>
+          <version>${changesPluginVersion}</version>          
+        </plugin>
+      </plugins>
+    </pluginManagement>    
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changes-plugin</artifactId>
+        <version>${changesPluginVersion}</version>    
+        <executions>
+          <execution>
+            <id>validate-changes</id>
+            <phase>pre-site</phase>
+            <goals>
+              <goal>changes-validate</goal>
+            </goals>
+            <configuration>
+              <failOnError>true</failOnError>
+            </configuration>
+          </execution>
+        </executions>              
+      </plugin>
+    </plugins>
+  </build>  
+  <reporting>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-changes-plugin</artifactId>
+        <version>@pom.version@</version>
+        <configuration>
+          <issueLinkTemplatePerSystem>
+            <default>http://myjira/browse/%ISSUE%</default>
+            <qc>http://localhost/%ISSUE%</qc>
+            <redmine>http://www.redmine.org/show/issue/%ISSUE%</redmine>
+          </issueLinkTemplatePerSystem>
+          <addActionDate>true</addActionDate>
+        </configuration>
+        <reportSets>
+          <reportSet>
+            <reports>
+              <report>changes-report</report>
+            </reports>
+          </reportSet>
+        </reportSets>
+      </plugin>
+    </plugins>
+  </reporting>
+  
+</project>

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml?rev=797966&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml (added)
+++ maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml Sun Jul 26 18:00:17 2009
@@ -0,0 +1,53 @@
+<!--
+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.
+-->
+
+<document xmlns="http://maven.apache.org/changes/1.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/xsd/changes-1.0.0.xsd">
+  <properties>
+    <title>Changes report Project</title>
+    <author email="zloug@toto.com">Mr Zloug</author>
+  </properties>
+  <body>
+    <release version="1.1" date="2005-03-01" description="Subsequent release">
+      <action dev="me" type="add">
+        Added additional documentation on how to configure the plugin.
+      </action>
+      <action dev="me" type="fix" issue="MCHANGES-88">
+        Enable retrieving component-specific issues.
+      </action>
+      <action dev="me" type="fix" issue="1212" system="qc">
+        Enable retrieving component-specific issues.
+      </action>      
+      <action dev="TheOneAndOnly" type="update" issue="88" system="redmine">
+        Updated library dependency.
+      </action>
+      <action dev="jruiz" type="remove" due-to="others" due-to-email="users@users.com">
+        The element type " link " must be terminated by the matching end-tag.
+        Deleted the erroneous code.
+      </action>
+    </release>
+
+    <release version="1.0" date="2005-01-01" description="First release">
+      <action dev="me" type="update" date="2008-01-01">
+        Uploaded documentation on how to use the plugin.
+      </action>
+    </release>
+  </body>
+</document>

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/src/changes/changes.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh?rev=797966&view=auto
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh (added)
+++ maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh Sun Jul 26 18:00:17 2009
@@ -0,0 +1,79 @@
+
+/*
+ * 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.
+ */
+
+import java.io.*;
+import java.util.*;
+import java.util.jar.*;
+import org.codehaus.plexus.util.*;
+
+boolean result = true;
+
+try
+{
+    File report = new File( basedir, "target/site/changes-report.html" );
+    if ( !report.exists() || report.isDirectory() )
+    {
+        System.err.println( "report file is missing or a directory." );
+        return false;
+    }
+    FileInputStream fis = new FileInputStream ( report );
+    String reportContent = IOUtil.toString ( fis );    
+    
+    int indexOf = reportContent.indexOf( "Changes Report" );
+    if ( indexOf < 0)
+    {
+      System.err.println( "changes-report.html doesn't contains Changes Report title" );
+      return false;
+    }    
+    
+    indexOf = reportContent.indexOf( "href=\"http://myjira/browse/MCHANGES-88\"" );
+    if ( indexOf < 0)
+    {
+      System.err.println( "changes-report.html doesn't contains jira issue link" );
+      return false;
+    }
+    indexOf = reportContent.indexOf( "href=\"http://localhost/1212\"" );
+    if ( indexOf < 0)
+    {
+      System.err.println( "changes-report.html doesn't contains qc issue link" );
+      return false;
+    }    
+    indexOf = reportContent.indexOf( "href=\"http://www.redmine.org/show/issue/88\"" );
+    if ( indexOf < 0)
+    {
+      System.err.println( "changes-report.html doesn't contains redmine issue link" );
+      return false;
+    }    
+    indexOf = reportContent.indexOf( "2008-01-01" );
+    if ( indexOf < 0)
+    {
+      System.err.println( "changes-report.html doesn't contains date 2008-01-01" );
+      return false;
+    }     
+    
+    
+}
+catch( Throwable e )
+{
+    e.printStackTrace();
+    result = false;
+}
+
+return result;

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-changes-plugin/src/it/report-changes-system-noissuemanagement/verify.bsh
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java?rev=797966&r1=797965&r2=797966&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java (original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesReportGenerator.java Sun Jul 26 18:00:17 2009
@@ -84,7 +84,10 @@
         {
             this.issueLinksPerSystem = new HashMap();
         }
-        this.issueLinksPerSystem.put( DEFAULT_ISSUE_SYSTEM_KEY, issueLink );
+        if ( !this.issueLinksPerSystem.containsKey( DEFAULT_ISSUE_SYSTEM_KEY ) )
+        {
+            this.issueLinksPerSystem.put( DEFAULT_ISSUE_SYSTEM_KEY, issueLink );
+        }
     }
 
     /**
@@ -131,7 +134,7 @@
 
     /**
      * Checks whether links to the issues can be generated.
-     *
+     * 
      * @return <code>true</code> if issue links can be generated, <code>false</code> otherwise.
      */
     public boolean canGenerateIssueLinks( String system )
@@ -141,8 +144,19 @@
             return false;
         }
         String issueLink = (String) this.issueLinksPerSystem.get( system );
-        return !StringUtils.isBlank( issueLink )
-            && ( !StringUtils.isBlank( getUrl() ) || issueLink.indexOf( URL_TOKEN ) < 0 );
+
+        // If the issue entry is blank no links possible
+        if ( StringUtils.isBlank( issueLink ) )
+        {
+            return false;
+        }
+
+        // If we have %URL% then the URL must be set.
+        if ( issueLink.indexOf( URL_TOKEN ) >= 0 && StringUtils.isBlank( getUrl() ) )
+        {
+            return false;
+        }
+        return true;
     }
 
     public boolean canGenerateIssueLinks()
@@ -176,11 +190,11 @@
 
     private void constructActions( Sink sink, List actionList, ResourceBundle bundle )
     {
-        if( actionList.isEmpty() )
+        if ( actionList.isEmpty() )
         {
             sink.paragraph();
 
-            sink.text( bundle.getString("report.changes.text.no.changes") );
+            sink.text( bundle.getString( "report.changes.text.no.changes" ) );
 
             sink.paragraph_();
         }
@@ -257,8 +271,8 @@
     {
         sink.section2();
 
-        sinkSectionTitle2Anchor( sink, bundle.getString( "report.changes.label.releasehistory" ), bundle
-            .getString( "report.changes.label.releasehistory" ) );
+        sinkSectionTitle2Anchor( sink, bundle.getString( "report.changes.label.releasehistory" ),
+                                 bundle.getString( "report.changes.label.releasehistory" ) );
 
         List releaseList = report.getReleaseList();
 
@@ -292,13 +306,13 @@
         sink.table_();
 
         // @todo Temporarily commented out until MCHANGES-46 is completely solved
-        //        sink.rawText( bundle.getString( "report.changes.text.rssfeed" ) );
-        //        sink.text( " " );
-        //        sink.link( "changes.rss" );
-        //        sinkFigure( "images/rss.png", sink );
-        //        sink.link_();
+        // sink.rawText( bundle.getString( "report.changes.text.rssfeed" ) );
+        // sink.text( " " );
+        // sink.link( "changes.rss" );
+        // sinkFigure( "images/rss.png", sink );
+        // sink.link_();
         //
-        //        sink.lineBreak();
+        // sink.lineBreak();
 
         sink.section2_();
     }
@@ -327,10 +341,14 @@
         String parseLink;
         String issueLink = (String) this.issueLinksPerSystem.get( system );
         parseLink = issueLink.replaceFirst( ISSUE_TOKEN, issue );
-
         if ( parseLink.indexOf( URL_TOKEN ) >= 0 )
         {
-            String url = this.url.substring( 0, this.url.lastIndexOf( "/" ) );
+            String url = getUrl();
+            // remove the trailing slash if it exists.
+            if ( url.endsWith( "/" ) )
+            {
+                url = url.substring( 0, url.length() - 1 );
+            }
             parseLink = parseLink.replaceFirst( URL_TOKEN, url );
         }
 
@@ -561,7 +579,6 @@
     }
 
     /**
-     *
      * @param sink
      * @param action
      * @param bundle
@@ -578,20 +595,20 @@
             namesEmailMap.put( action.getDueTo(), action.getDueToEmail() );
         }
 
-        for (Iterator iterator = dueTos.iterator();iterator.hasNext();)
+        for ( Iterator iterator = dueTos.iterator(); iterator.hasNext(); )
         {
             DueTo dueTo = (DueTo) iterator.next();
             namesEmailMap.put( dueTo.getName(), dueTo.getEmail() );
         }
 
-        if (namesEmailMap.isEmpty())
+        if ( namesEmailMap.isEmpty() )
         {
             return;
         }
 
         sink.text( " " + bundle.getString( "report.changes.text.thanx" ) + " " );
         int i = 0;
-        for (Iterator iterator = namesEmailMap.keySet().iterator(); iterator.hasNext();)
+        for ( Iterator iterator = namesEmailMap.keySet().iterator(); iterator.hasNext(); )
         {
             String currentDueTo = (String) iterator.next();
             String currentDueToEmail = (String) namesEmailMap.get( currentDueTo );