Author: dennisl Date: Thu Dec 30 20:54:23 2010 New Revision: 1053999 URL: http://svn.apache.org/viewvc?rev=1053999&view=rev Log: o Refactoring: move the reading of issues from the xml file to JiraMojo and just feed the report generator a list of issues to present
Modified: 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/JiraReportGenerator.java 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=1053999&r1=1053998&r2=1053999&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 Thu Dec 30 20:54:23 2010 @@ -20,6 +20,7 @@ package org.apache.maven.plugin.jira; */ import java.io.File; +import java.util.List; import java.util.Locale; import java.util.ResourceBundle; @@ -246,10 +247,18 @@ public class JiraMojo if ( jiraXmlPath.isFile() ) { - report = new JiraReportGenerator( jiraXmlPath, columnNames, project.getVersion(), - onlyCurrentVersion ); + JiraXML jira = new JiraXML( jiraXmlPath ); + List issueList = jira.getIssueList(); - report.doGenerateReport( getBundle( locale ), getSink(), getLog() ); + report = new JiraReportGenerator( columnNames ); + + if ( onlyCurrentVersion ) + { + issueList = JiraHelper.getIssuesForVersion( issueList, project.getVersion() ); + getLog().info( "The JIRA Report will contain issues only for the current version." ); + } + + report.doGenerateReport( getBundle( locale ), getSink(), issueList ); } else { Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java?rev=1053999&r1=1053998&r2=1053999&view=diff ============================================================================== --- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java (original) +++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/jira/JiraReportGenerator.java Thu Dec 30 20:54:23 2010 @@ -21,10 +21,8 @@ package org.apache.maven.plugin.jira; import org.apache.maven.doxia.sink.Sink; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.logging.Log; import org.apache.maven.reporting.MavenReportException; -import java.io.File; import java.util.Iterator; import java.util.List; import java.util.ResourceBundle; @@ -64,33 +62,17 @@ public class JiraReportGenerator private int[] columnOrder; - private String currentVersion = null; - - private JiraXML jira; - - private boolean onlyCurrentVersion = false; - public JiraReportGenerator() { } /** - * - * @param xmlFile An xml file containing issues from JIRA * @param columnNames The names of the columns to include in the report - * @param currentVersion The current version of the project - * @param onlyCurrentVersion If only issues for the current version will be included in the report - * @todo Move reading of xml file to JiraMojo and feed an issueList to this report generator */ - public JiraReportGenerator( File xmlFile, String columnNames, String currentVersion, boolean onlyCurrentVersion ) + public JiraReportGenerator( String columnNames ) throws MavenReportException { - this.currentVersion = currentVersion; - this.onlyCurrentVersion = onlyCurrentVersion; - - jira = new JiraXML( xmlFile ); - String[] columnNamesArray = columnNames.split( "," ); int validColumnNames = 0; columnOrder = new int[columnNamesArray.length]; @@ -131,17 +113,9 @@ public class JiraReportGenerator sinkEndReport( sink ); } - public void doGenerateReport( ResourceBundle bundle, Sink sink, Log log ) + public void doGenerateReport( ResourceBundle bundle, Sink sink, List issueList ) throws MojoExecutionException { - List issueList = jira.getIssueList(); - - if ( onlyCurrentVersion ) - { - issueList = JiraHelper.getIssuesForVersion( issueList, currentVersion ); - log.info( "The JIRA Report will contain issues only for the current version." ); - } - sinkBeginReport( sink, bundle ); constructHeaderRow( sink, issueList, bundle );