maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1055197 - in /maven/plugins/trunk/maven-changes-plugin: ./ src/main/java/org/apache/maven/plugin/announcement/ src/main/java/org/apache/maven/plugin/issues/ src/main/java/org/apache/maven/plugin/jira/
Date Tue, 04 Jan 2011 21:55:01 GMT
Author: dennisl
Date: Tue Jan  4 21:55:00 2011
New Revision: 1055197

URL: http://svn.apache.org/viewvc?rev=1055197&view=rev
Log:
[MCHANGES-215] Make it possible to add the columns created, id and updated to a JIRA Report

o Improve handling of null and parse errors
o Allow configuration of the date pattern that is used in the JIRA XML file

Modified:
    maven/plugins/trunk/maven-changes-plugin/pom.xml
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java

Modified: maven/plugins/trunk/maven-changes-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/pom.xml?rev=1055197&r1=1055196&r2=1055197&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-changes-plugin/pom.xml Tue Jan  4 21:55:00 2011
@@ -450,7 +450,7 @@ under the License.
               </issueLinkTemplatePerSystem>
               <xmlPath>${basedir}/src/site/changes/sample-changes.xml</xmlPath>
               <!-- For JIRA-report -->
-              <columnNames>Type,Key,Summary,Assignee,Status,Resolution,Fix Version</columnNames>
+              <columnNames>Type,Key,Summary,Assignee,Status,Resolution,Created</columnNames>
               <maxEntries>200</maxEntries>
               <onlyCurrentVersion>true</onlyCurrentVersion>
               <resolutionIds>Closed</resolutionIds>

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java?rev=1055197&r1=1055196&r2=1055197&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/announcement/AnnouncementMojo.java
Tue Jan  4 21:55:00 2011
@@ -632,7 +632,7 @@ public class AnnouncementMojo
 
             if ( jiraXMLFile.exists() )
             {
-                JiraXML jiraParser = new JiraXML( jiraXMLFile, jiraXmlEncoding );
+                JiraXML jiraParser = new JiraXML( jiraXMLFile, jiraXmlEncoding, getLog(),
null );
 
                 List issues = jiraParser.getIssueList();
 

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java?rev=1055197&r1=1055196&r2=1055197&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/issues/IssuesReportGenerator.java
Tue Jan  4 21:55:00 2011
@@ -38,6 +38,11 @@ import java.util.ResourceBundle;
 public class IssuesReportGenerator
 {
     /**
+     * Fallback value that is used if date field are not available.
+     */
+    private static final String NOT_AVAILABLE = "n/a";
+
+    /**
      * Holds the id:s for the columns to include in the report, in the order
      * that they should appear in the report.
      */
@@ -185,7 +190,12 @@ public class IssuesReportGenerator
                         break;
 
                     case IssuesReportHelper.COLUMN_CREATED:
-                        sinkCell( sink, df.format( issue.getCreated() ) );
+                        String created = NOT_AVAILABLE;
+                        if ( issue.getCreated() != null )
+                        {
+                            created = df.format( issue.getCreated() );
+                        }
+                        sinkCell( sink, created );
                         break;
 
                     case IssuesReportHelper.COLUMN_FIX_VERSION:
@@ -233,7 +243,12 @@ public class IssuesReportGenerator
                         break;
 
                     case IssuesReportHelper.COLUMN_UPDATED:
-                        sinkCell( sink, df.format( issue.getUpdated() ) );
+                        String updated = NOT_AVAILABLE;
+                        if ( issue.getUpdated() != null )
+                        {
+                            updated = df.format( issue.getUpdated() );
+                        }
+                        sinkCell( sink, updated );
                         break;
 
                     case IssuesReportHelper.COLUMN_VERSION:

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java?rev=1055197&r1=1055196&r2=1055197&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraMojo.java
Tue Jan  4 21:55:00 2011
@@ -262,6 +262,15 @@ public class JiraMojo
     private boolean onlyCurrentVersion;
 
     /**
+     * The pattern used by dates in the JIRA XML-file. This is used to parse
+     * the Created and Updated fields.
+     *
+     * @parameter default-value="EEE, d MMM yyyy HH:mm:ss Z"
+     * @since 2.4
+     */
+    private String jiraDatePattern;
+
+    /**
      * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
      */
     public boolean canGenerateReport()
@@ -284,7 +293,7 @@ public class JiraMojo
 
             if ( jiraXmlPath.isFile() )
             {
-                JiraXML jira = new JiraXML( jiraXmlPath, jiraXmlEncoding );
+                JiraXML jira = new JiraXML( jiraXmlPath, jiraXmlEncoding, getLog(), jiraDatePattern
);
                 List issueList = jira.getIssueList();
 
                 List columnIds = IssuesReportHelper.getColumnIds( columnNames, JIRA_COLUMNS
);

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java?rev=1055197&r1=1055196&r2=1055197&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraXML.java
Tue Jan  4 21:55:00 2011
@@ -32,6 +32,7 @@ import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
 
 import org.apache.maven.plugin.issues.Issue;
+import org.apache.maven.plugin.logging.Log;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -53,18 +54,34 @@ public class JiraXML
 
     private String currentParent = "";
 
+    private String datePattern = null;
+
     private Issue issue;
 
-    private SimpleDateFormat sdf;
+    private Log log = null;
+
+    private SimpleDateFormat sdf = null;
 
-    public JiraXML( File xmlPath, String encoding )
+    public JiraXML( File xmlPath, String encoding, Log log, String datePattern )
     {
+        this.log = log;
+        this.datePattern = datePattern;
+
+        if ( datePattern == null )
+        {
+            sdf = null;
+        }
+        else
+        {
+            // @todo Do we need to be able to configure the locale of the JIRA server as
well?
+            sdf = new SimpleDateFormat( datePattern, Locale.ENGLISH );
+        }
+
         SAXParserFactory factory = SAXParserFactory.newInstance();
         FileInputStream fis = null;
 
         issueList = new ArrayList();
 
-        sdf = new SimpleDateFormat( "EEE, d MMM yyyy HH:mm:ss Z (z)", Locale.ENGLISH );
         try
         {
             SAXParser saxParser = factory.newSAXParser();
@@ -179,7 +196,7 @@ public class JiraXML
         {
             issue.setTitle( currentElement.toString().trim() );
         }
-        else if ( qName.equals( "created" ) && currentParent.equals( "item" ) )
+        else if ( qName.equals( "created" ) && currentParent.equals( "item" ) &&
sdf != null )
         {
             try
             {
@@ -187,10 +204,10 @@ public class JiraXML
             }
             catch ( ParseException e )
             {
-                throw new SAXException( "Unable to parse the date: 'created'.", e );
+                log.warn( "Element \"Created\". " + e.getMessage() + ". Using the pattern
\"" + datePattern + "\"");
             }
         }
-        else if ( qName.equals( "updated" ) && currentParent.equals( "item" ) )
+        else if ( qName.equals( "updated" ) && currentParent.equals( "item" ) &&
sdf != null )
         {
             try
             {
@@ -198,7 +215,7 @@ public class JiraXML
             }
             catch ( ParseException e )
             {
-                throw new SAXException( "Unable to parse the date: 'updated'.", e );
+                log.warn( "Element \"Updated\". " + e.getMessage() + ". Using the pattern
\"" + datePattern + "\"");
             }
         }
 



Mime
View raw message