org.apache.maven.plugin.changes.IssueAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-changes-plugin Show documentation
Show all versions of maven-changes-plugin Show documentation
Creates a release history for inclusion into the site and assists in generating an announcement mail.
package org.apache.maven.plugin.changes;
/*
* 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 org.apache.maven.plugin.issues.Issue;
import org.apache.maven.plugins.changes.model.Action;
import org.apache.maven.plugins.changes.model.Release;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* An adapter that can adapt issue management system data models to the data model used
* in the changes.xml file.
*
* @author Dennis Lundberg
* @version $Id: IssueAdapter.java 1055796 2011-01-06 09:15:06Z dennisl $
* @since 2.4
*/
public class IssueAdapter
{
/**
* Adapt a List
of Issue
s to a
* List
of Release
s.
*
* @param issues The issues
* @return A list of releases
*/
public static List getReleases( List issues )
{
// A Map of releases keyed by fixVersion
Map releasesMap = new HashMap();
// Loop through all issues looking for fixVersions
for ( int i = 0; i < issues.size(); i++ )
{
Issue issue = (Issue) issues.get( i );
// Do NOT create a release for issues that lack a fixVersion
if ( issue.getFixVersions() != null )
{
for ( Iterator iterator = issue.getFixVersions().iterator(); iterator.hasNext(); )
{
String fixVersion = (String) iterator.next();
// Try to get a matching Release from the map
Release release = (Release) releasesMap.get( fixVersion );
if ( release == null )
{
// Add a new Release to the Map if it wasn't there
release = new Release();
release.setVersion( fixVersion );
releasesMap.put( fixVersion, release );
}
// Add this issue as an Action to this release
Action action = createAction( issue );
release.addAction( action );
}
}
}
// Extract the releases from the Map to a List
List releasesList = new ArrayList();
for ( Iterator iterator = releasesMap.entrySet().iterator(); iterator.hasNext(); )
{
Release o = (Release) ( (Map.Entry) iterator.next() ).getValue();
releasesList.add( o );
}
return releasesList;
}
/**
* Create an Action
from an issue.
*
* @param issue The issue to extract the information from
* @return An Action
*/
public static Action createAction( Issue issue )
{
Action action = new Action();
// @todo We need to add something like issue.getPresentationIdentifier() to be able to support other IMSes beside JIRA
action.setIssue( issue.getKey() );
// @todo To support types for different IMSes we need some way to map these values to the ones used in a particular IMS
String type = "";
if ( issue.getType().equals( "Bug" ) )
{
type = "fix";
}
else if ( issue.getType().equals( "New Feature" ) )
{
type = "add";
}
else if ( issue.getType().equals( "Improvement" ) )
{
type = "update";
}
action.setType( type );
action.setDev( issue.getAssignee() );
// Set dueTo to the empty String instead of null to make Velocity happy
action.setDueTo( "" );
//action.setDueTo( issue.getReporter() );
action.setAction( issue.getSummary() );
return action;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy