Author: dennisl Date: Sun Jan 13 09:15:35 2008 New Revision: 611599 URL: http://svn.apache.org/viewvc?rev=611599&view=rev Log: [MCHANGES-92] JIRA Report Improvements Submitted by: Niall Pemberton Reviewed by: Dennis Lundberg
o Add configuration of which columns to include and the order they appear in. 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 maven/plugins/trunk/maven-changes-plugin/src/main/resources/jira-report.properties 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=611599&r1=611598&r2=611599&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 Sun Jan 13 09:15:35 2008 @@ -103,11 +103,12 @@ /** * Sets the fix version id(s) that you want to limit your report to include. - * These are JIRA's internal version ids, NOT the human readable display ones. + * These are JIRA's internal version ids, <b>NOT</b> the human readable display ones. * Multiple fix versions can be separated by commas. - * If this is set to empty - that means all fix versions. + * If this is set to empty - that means all fix versions will be included. * * @parameter default-value="" + * @since 2.0-beta-4 */ private String fixVersionIds; @@ -155,10 +156,28 @@ * values can be separated by commas. * * @parameter default-value="" + * @since 2.0-beta-4 */ private String typeIds; /** + * Sets the column names that you want to show in the report. The columns + * will appear in the report in the same order as you specify them here. + * Multiple values can be separated by commas. + * <p> + * Valid columns are: <code>Key</code>, <code>Summary</code>, + * <code>Status</code>, <code>Resolution</code>, <code>Assignee</code>, + * <code>Reporter</code>, <code>Type</code>, <code>Priority</code>, + * <code>Version</code>, <code>Fix Version</code> and + * <code>Component</code>. + * </p> + * + * @parameter default-value="Key,Summary,Status,Resolution,Assignee" + * @since 2.0-beta-4 + */ + private String columnNames; + + /** * Defines the JIRA username for authentication into a private JIRA installation. * * @parameter default-value="" @@ -209,7 +228,7 @@ if ( new File( jiraXmlPath ).exists() ) { - report = new JiraReportGenerator( jiraXmlPath ); + report = new JiraReportGenerator( jiraXmlPath, columnNames ); report.doGenerateReport( getBundle( locale ), getSink() ); } @@ -219,6 +238,12 @@ report.doGenerateEmptyReport( getBundle( locale ), getSink() ); } + } + catch ( MavenReportException mre ) + { + // Rethrow this error from JiraReportGenerator( String, String ) + // so that the build fails + throw mre; } catch ( Exception e ) { 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=611599&r1=611598&r2=611599&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 Sun Jan 13 09:15:35 2008 @@ -23,6 +23,7 @@ import java.util.ResourceBundle; import org.apache.maven.doxia.sink.Sink; +import org.apache.maven.reporting.MavenReportException; /** * Generates a JIRA report. @@ -31,6 +32,34 @@ */ public class JiraReportGenerator { + private static final int COLUMN_KEY = 0; + private static final int COLUMN_SUMMARY = 1; + private static final int COLUMN_STATUS = 2; + private static final int COLUMN_RESOLUTION = 3; + private static final int COLUMN_ASSIGNEE = 4; + private static final int COLUMN_REPORTER = 5; + private static final int COLUMN_TYPE = 6; + private static final int COLUMN_PRIORITY = 7; + private static final int COLUMN_VERSION = 8; + private static final int COLUMN_FIX_VERSION = 9; + private static final int COLUMN_COMPONENT = 10; + + private static final String[] JIRA_COLUMNS = new String[] { + /* 0 */ "Key", + /* 1 */ "Summary", + /* 2 */ "Status", + /* 3 */ "Resolution", + /* 4 */ "Assignee", + /* 5 */ "Reporter", + /* 6 */ "Type", + /* 7 */ "Priority", + /* 8 */ "Version", + /* 9 */ "Fix Version", + /* 10 */ "Component" + }; + + private int[] columnOrder; + private JiraXML jira; public JiraReportGenerator() @@ -38,9 +67,36 @@ } - public JiraReportGenerator( String xmlPath ) + public JiraReportGenerator( String xmlPath, String columnNames ) + throws MavenReportException { jira = new JiraXML( xmlPath ); + + String[] columnNamesArray = columnNames.split( "," ); + int validColumnNames = 0; + columnOrder = new int[columnNamesArray.length]; + for ( int i = 0; i < columnOrder.length; i++ ) + { + // Default to -1, indicating that the column should not be included in the report + columnOrder[i] = -1; + for ( int columnIndex = 0; columnIndex < JIRA_COLUMNS.length; columnIndex++ ) + { + String columnName = columnNamesArray[i].trim(); + if ( JIRA_COLUMNS[columnIndex].equalsIgnoreCase( columnName ) ) + { + // Found a valid column name - add it + columnOrder[i] = columnIndex; + validColumnNames++; + break; + } + } + } + if ( validColumnNames == 0 ) + { + // This can happen if the user has configured column names and they are all invalid + throw new MavenReportException( + "maven-changes-plugin: None of the configured columnNames '" + columnNames + "' are valid." ); + } } public void doGenerateEmptyReport( ResourceBundle bundle, Sink sink ) @@ -76,15 +132,60 @@ sink.tableRow(); - sinkHeader( sink, bundle.getString( "report.jira.label.key" ) ); - - sinkHeader( sink, bundle.getString( "report.jira.label.summary" ) ); - - sinkHeader( sink, bundle.getString( "report.jira.label.status" ) ); - - sinkHeader( sink, bundle.getString( "report.jira.label.resolution" ) ); + for ( int columnIndex = 0; columnIndex < columnOrder.length; columnIndex++ ) + { + switch ( columnOrder[columnIndex] ) + { + case COLUMN_KEY: + sinkHeader( sink, bundle.getString( "report.jira.label.key" ) ); + break; + + case COLUMN_SUMMARY: + sinkHeader( sink, bundle.getString( "report.jira.label.summary" ) ); + break; + + case COLUMN_STATUS: + sinkHeader( sink, bundle.getString( "report.jira.label.status" ) ); + break; + + case COLUMN_RESOLUTION: + sinkHeader( sink, bundle.getString( "report.jira.label.resolution" ) ); + break; + + case COLUMN_ASSIGNEE: + sinkHeader( sink, bundle.getString( "report.jira.label.by" ) ); + break; + + case COLUMN_REPORTER: + sinkHeader( sink, bundle.getString( "report.jira.label.reporter" ) ); + break; + + case COLUMN_TYPE: + sinkHeader( sink, bundle.getString( "report.jira.label.type" ) ); + break; + + case COLUMN_PRIORITY: + sinkHeader( sink, bundle.getString( "report.jira.label.priority" ) ); + break; + + case COLUMN_VERSION: + sinkHeader( sink, bundle.getString( "report.jira.label.version" ) ); + break; + + case COLUMN_FIX_VERSION: + sinkHeader( sink, bundle.getString( "report.jira.label.fixVersion" ) ); + break; + + case COLUMN_COMPONENT: + sinkHeader( sink, bundle.getString( "report.jira.label.component" ) ); + break; + + default: + // Do not add a header for this column + break; + } - sinkHeader( sink, bundle.getString( "report.jira.label.by" ) ); + } sink.tableRow_(); } @@ -102,23 +203,63 @@ sink.tableRow(); - sink.tableCell(); - - sink.link( issue.getLink() ); - - sink.text( issue.getKey() ); - - sink.link_(); - - sink.tableCell_(); - - sinkCell( sink, issue.getSummary() ); - - sinkCell( sink, issue.getStatus() ); - - sinkCell( sink, issue.getResolution() ); - - sinkCell( sink, issue.getAssignee() ); + for ( int columnIndex = 0; columnIndex < columnOrder.length; columnIndex++ ) + { + switch ( columnOrder[columnIndex] ) + { + case COLUMN_KEY: + sink.tableCell(); + sink.link( issue.getLink() ); + sink.text( issue.getKey() ); + sink.link_(); + sink.tableCell_(); + break; + + case COLUMN_SUMMARY: + sinkCell( sink, issue.getSummary() ); + break; + + case COLUMN_STATUS: + sinkCell( sink, issue.getStatus() ); + break; + + case COLUMN_RESOLUTION: + sinkCell( sink, issue.getResolution() ); + break; + + case COLUMN_ASSIGNEE: + sinkCell( sink, issue.getAssignee() ); + break; + + case COLUMN_REPORTER: + sinkCell( sink, issue.getReporter() ); + break; + + case COLUMN_TYPE: + sinkCell( sink, issue.getType() ); + break; + + case COLUMN_PRIORITY: + sinkCell( sink, issue.getPriority() ); + break; + + case COLUMN_VERSION: + sinkCell( sink, issue.getVersion() ); + break; + + case COLUMN_FIX_VERSION: + sinkCell( sink, issue.getFixVersion() ); + break; + + case COLUMN_COMPONENT: + sinkCell( sink, issue.getComponent() ); + break; + + default: + // Do not add a cell for this column + break; + } + } sink.tableRow_(); } Modified: maven/plugins/trunk/maven-changes-plugin/src/main/resources/jira-report.properties URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/resources/jira-report.properties?rev=611599&r1=611598&r2=611599&view=diff ============================================================================== --- maven/plugins/trunk/maven-changes-plugin/src/main/resources/jira-report.properties (original) +++ maven/plugins/trunk/maven-changes-plugin/src/main/resources/jira-report.properties Sun Jan 13 09:15:35 2008 @@ -25,3 +25,9 @@ report.jira.label.status=Status report.jira.label.resolution=Resolution report.jira.label.by=By +report.jira.label.reporter=Reporter +report.jira.label.type=Type +report.jira.label.priority=Priority +report.jira.label.version=Version +report.jira.label.fixVersion=Fix Version +report.jira.label.component=Component