maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From denn...@apache.org
Subject svn commit: r1098351 - in /maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin: announcement/AnnouncementMojo.java changes/ChangesCheckMojo.java changes/IssueAdapter.java changes/ReleaseUtils.java
Date Sun, 01 May 2011 15:17:25 GMT
Author: dennisl
Date: Sun May  1 15:17:25 2011
New Revision: 1098351

URL: http://svn.apache.org/viewvc?rev=1098351&view=rev
Log:
[MCHANGES-210] Update to Java 5

- Start using generics in IssueAdapter and ReleaseUtils.

Modified:
    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/changes/ChangesCheckMojo.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/IssueAdapter.java
    maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ReleaseUtils.java

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=1098351&r1=1098350&r2=1098351&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
Sun May  1 15:17:25 2011
@@ -29,12 +29,11 @@ import java.util.List;
 import java.util.Map;
 
 import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.changes.IssueAdapter;
 import org.apache.maven.plugin.changes.ChangesXML;
+import org.apache.maven.plugin.changes.IssueAdapter;
 import org.apache.maven.plugin.changes.ProjectUtils;
 import org.apache.maven.plugin.changes.ReleaseUtils;
 import org.apache.maven.plugin.issues.Issue;
-import org.apache.maven.plugin.jira.JiraXML;
 import org.apache.maven.plugin.trac.TracDownloader;
 import org.apache.maven.plugins.changes.model.Release;
 import org.apache.maven.project.MavenProject;
@@ -428,14 +427,14 @@ public class AnnouncementMojo
             }
 
             // Fetch releases from the configured issue management systems
-            List releases = null;
+            List<Release> releases = null;
 
             if ( issueManagementSystems.contains( CHANGES_XML ) )
             {
                 if ( getXmlPath().exists() )
                 {
                     ChangesXML changesXML = new ChangesXML( getXmlPath(), getLog() );
-                    List changesReleases = changesXML.getReleaseList();
+                    List<Release> changesReleases = releaseUtils.convertReleaseList(
changesXML.getReleaseList() );
                     releases = releaseUtils.mergeReleases( releases, changesReleases );
                     getLog().info( "Including issues from file " + getXmlPath() + " in announcement..."
);
                 }
@@ -449,7 +448,7 @@ public class AnnouncementMojo
             {
                 if ( ProjectUtils.validateIfIssueManagementComplete( project, JIRA, "JIRA
announcement", getLog() ) )
                 {
-                    List jiraReleases = getJiraReleases();
+                    List<Release> jiraReleases = getJiraReleases();
                     releases = releaseUtils.mergeReleases( releases, jiraReleases );
                     getLog().info( "Including issues from JIRA in announcement..." );
                 }
@@ -464,7 +463,7 @@ public class AnnouncementMojo
             {
                 if ( ProjectUtils.validateIfIssueManagementComplete( project, TRAC, "Trac
announcement", getLog() ) )
                 {
-                    List tracReleases = getTracReleases();
+                    List<Release> tracReleases = getTracReleases();
                     releases = releaseUtils.mergeReleases( releases, tracReleases );
                     getLog().info( "Including issues from Trac in announcement..." );
                 }
@@ -503,13 +502,13 @@ public class AnnouncementMojo
      * @param releases A <code>List</code> of <code>Release</code>s
      * @throws MojoExecutionException
      */
-    public void doGenerate( List releases )
+    public void doGenerate( List<Release> releases )
         throws MojoExecutionException
     {
         doGenerate( releases, releaseUtils.getLatestRelease( releases, getVersion() )  );
     }
 
-    protected void doGenerate( List releases, Release release )
+    protected void doGenerate( List<Release> releases, Release release )
         throws MojoExecutionException
     {
         try
@@ -641,7 +640,7 @@ public class AnnouncementMojo
         }
     }
 
-    protected List getJiraReleases()
+    protected List<Release> getJiraReleases()
         throws MojoExecutionException
     {
         JiraDownloader jiraDownloader = new JiraDownloader();
@@ -684,7 +683,7 @@ public class AnnouncementMojo
         }
     }
 
-    private List getReleases( List<Issue> issues )
+    private List<Release> getReleases( List<Issue> issues )
     {
         if ( issues.isEmpty() )
         {
@@ -696,7 +695,7 @@ public class AnnouncementMojo
         }
     }
 
-    protected List getTracReleases()
+    protected List<Release> getTracReleases()
         throws MojoExecutionException
     {
         TracDownloader issueDownloader = new TracDownloader();

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesCheckMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesCheckMojo.java?rev=1098351&r1=1098350&r2=1098351&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesCheckMojo.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ChangesCheckMojo.java
Sun May  1 15:17:25 2011
@@ -22,6 +22,7 @@ package org.apache.maven.plugin.changes;
 import java.io.File;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.plugin.AbstractMojo;
@@ -76,7 +77,9 @@ public class ChangesCheckMojo extends Ab
         if ( xmlPath.exists() )
         {
             ChangesXML xml = new ChangesXML( xmlPath, getLog() );
-            Release release = releaseUtils.getLatestRelease( xml.getReleaseList(), version
);
+            ReleaseUtils releaseUtils = new ReleaseUtils( getLog() );
+            Release release = releaseUtils.getLatestRelease( releaseUtils.convertReleaseList(
xml.getReleaseList() ),
+                                                             version );
             if ( !isValidDate( release.getDateRelease(), releaseDateFormat ) )
             {
                 throw new MojoExecutionException(

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/IssueAdapter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/IssueAdapter.java?rev=1098351&r1=1098350&r2=1098351&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/IssueAdapter.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/IssueAdapter.java
Sun May  1 15:17:25 2011
@@ -46,7 +46,7 @@ public class IssueAdapter
      * @param issues The issues
      * @return A list of releases
      */
-    public static List getReleases( List<Issue> issues )
+    public static List<Release> getReleases( List<Issue> issues )
     {
         // A Map of releases keyed by fixVersion
         Map<String,Release> releasesMap = new HashMap<String,Release>();
@@ -77,8 +77,7 @@ public class IssueAdapter
         }
 
         // Extract the releases from the Map to a List
-        // @todo Generify this list when Modello generates types collections from changes.xml
-        List/*<Release>*/ releasesList = new ArrayList/*<Release>*/();
+        List<Release> releasesList = new ArrayList<Release>();
         for ( Release release : releasesMap.values() )
         {
             releasesList.add( release );

Modified: maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ReleaseUtils.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ReleaseUtils.java?rev=1098351&r1=1098350&r2=1098351&view=diff
==============================================================================
--- maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ReleaseUtils.java
(original)
+++ maven/plugins/trunk/maven-changes-plugin/src/main/java/org/apache/maven/plugin/changes/ReleaseUtils.java
Sun May  1 15:17:25 2011
@@ -56,7 +56,7 @@ public class ReleaseUtils
      * @return A <code>Release</code> that matches the next release of the current
project
      * @throws org.apache.maven.plugin.MojoExecutionException If a release can't be found
      */
-    public Release getLatestRelease( List releases, String pomVersion )
+    public Release getLatestRelease( List<Release> releases, String pomVersion )
         throws MojoExecutionException
     {
         // Remove "-SNAPSHOT" from the end, if it's there
@@ -89,12 +89,10 @@ public class ReleaseUtils
      * @param version The version we want
      * @return A Release, or null if no release with the specified version can be found
      */
-    protected Release getRelease( List releases, String version )
+    protected Release getRelease( List<Release> releases, String version )
     {
-        Release release = null;
-        for ( int i = 0; i < releases.size(); i++ )
+        for ( Release release : releases )
         {
-            release = (Release) releases.get( i );
             if ( getLog().isDebugEnabled() )
             {
                 getLog().debug( "The release: " + release.getVersion()
@@ -136,11 +134,11 @@ public class ReleaseUtils
      * @param secondReleases Releases from the second issue tracker
      * @return A list containing the merged releases
      */
-    public List mergeReleases( final List firstReleases, final List secondReleases )
+    public List<Release> mergeReleases( final List<Release> firstReleases, final
List<Release> secondReleases )
     {
         if ( firstReleases == null && secondReleases == null )
         {
-            return Collections.EMPTY_LIST;
+            return Collections.emptyList();
         }
         if ( firstReleases == null )
         {
@@ -151,14 +149,13 @@ public class ReleaseUtils
             return firstReleases;
         }
 
-        List mergedReleases = new ArrayList();
+        List<Release> mergedReleases = new ArrayList<Release>();
 
         // Loop through the releases from the first issue tracker, merging in
         // actions from releases with the same version from the second issue
         // tracker
-        for ( Iterator iterator = firstReleases.iterator(); iterator.hasNext(); )
+        for ( Release firstRelease : firstReleases )
         {
-            Release firstRelease = (Release) iterator.next();
             Release secondRelease = getRelease( secondReleases, firstRelease.getVersion()
);
             if ( secondRelease != null )
             {
@@ -171,9 +168,8 @@ public class ReleaseUtils
         }
 
         // Handle releases that are only in the second issue tracker
-        for ( Iterator iterator = secondReleases.iterator(); iterator.hasNext(); )
+        for ( Release secondRelease : secondReleases )
         {
-            Release secondRelease = (Release) iterator.next();
             Release mergedRelease = getRelease( mergedReleases, secondRelease.getVersion()
);
             if ( mergedRelease == null )
             {
@@ -182,4 +178,25 @@ public class ReleaseUtils
         }
         return mergedReleases;
     }
+
+    /**
+     * Convert an untyped List of Release objects that comes from changes.xml
+     * into a typed List of Release objects.
+     *
+     * @param changesReleases An untyped List of Release objects
+     * @return A type List of Release objects
+     * @todo When Modello can generate typed collections this method is no longer needed
+     */
+    public List<Release> convertReleaseList( List changesReleases ) {
+        List<Release> releases = new ArrayList<Release>();
+
+        // Loop through the List of releases from changes.xml and casting each
+        // release to a Release
+        for ( Iterator iterator = changesReleases.iterator(); iterator.hasNext(); )
+        {
+            Release release = (Release) iterator.next();
+            releases.add( release );
+        }
+        return releases;
+    }
 }



Mime
View raw message