maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r1054693 - in /maven/maven-3/trunk: maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Date Mon, 03 Jan 2011 17:51:25 GMT
Author: bentmann
Date: Mon Jan  3 17:51:24 2011
New Revision: 1054693

URL: http://svn.apache.org/viewvc?rev=1054693&view=rev
Log:
o Restored API backward compat with 2.x and polished some code

Modified:
    maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
    maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java

Modified: maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java?rev=1054693&r1=1054692&r2=1054693&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
(original)
+++ maven/maven-3/trunk/maven-compat/src/main/java/org/apache/maven/repository/legacy/LegacyRepositorySystem.java
Mon Jan  3 17:51:24 2011
@@ -192,7 +192,12 @@ public class LegacyRepositorySystem
         VersionRange versionRange;
         try
         {
-            versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
+            String version = plugin.getVersion();
+            if ( StringUtils.isEmpty( version ) )
+            {
+                version = "RELEASE";
+            }
+            versionRange = VersionRange.createFromVersionSpec( version );
         }
         catch ( InvalidVersionSpecificationException e )
         {

Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java?rev=1054693&r1=1054692&r2=1054693&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
Mon Jan  3 17:51:24 2011
@@ -209,6 +209,10 @@ public class MavenProject
     @Deprecated
     public MavenProject( MavenProject project )
     {
+        repositorySystem = project.repositorySystem;
+        logger = project.logger;
+        mavenProjectBuilder = project.mavenProjectBuilder;
+        projectBuilderConfiguration = project.projectBuilderConfiguration;
         deepCopy( project );
     }
     
@@ -1113,49 +1117,47 @@ public class MavenProject
         return artifactMap;
     }
 
+    public void setPluginArtifacts( Set<Artifact> pluginArtifacts )
+    {
+        this.pluginArtifacts = pluginArtifacts;
+
+        this.pluginArtifactMap = null;
+    }
+
     public Set<Artifact> getPluginArtifacts()
     {
         if ( pluginArtifacts != null )
         {
             return pluginArtifacts;
         }
+
         pluginArtifacts = new HashSet<Artifact>();
+
         if ( repositorySystem != null )
         {
-            List<Plugin> plugins = getBuildPlugins();
-            for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext(); )
+            for ( Plugin p : getBuildPlugins() )
             {
-                Plugin p = (Plugin) i.next();
-
-                String version;
-                if ( StringUtils.isEmpty( p.getVersion() ) )
-                {
-                    version = "RELEASE";
-                }
-                else
-                {
-                    version = p.getVersion();
-                }
-
                 Artifact artifact = repositorySystem.createPluginArtifact( p );
 
-                if ( artifact == null )
-                {
-                    return pluginArtifacts;
-                }
-                else
+                if ( artifact != null )
                 {
                     pluginArtifacts.add( artifact );
                 }
             }
         }
+
         pluginArtifactMap = null;
+
         return pluginArtifacts;
     }
 
     public Map<String, Artifact> getPluginArtifactMap()
     {
-        pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts()
);
+        if ( pluginArtifactMap == null )
+        {
+            pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts()
);
+        }
+
         return pluginArtifactMap;
     }
 
@@ -1176,27 +1178,16 @@ public class MavenProject
         }
 
         reportArtifacts = new HashSet<Artifact>();
-        List<ReportPlugin> reports = getReportPlugins();
-        if ( reports != null )
+
+        if ( repositorySystem != null )
         {
-            for ( Iterator<ReportPlugin> i = reports.iterator(); i.hasNext(); )
+            for ( ReportPlugin p : getReportPlugins() )
             {
-                ReportPlugin p = (ReportPlugin) i.next();
-
-                String version;
-                if ( StringUtils.isEmpty( p.getVersion() ) )
-                {
-                    version = "RELEASE";
-                }
-                else
-                {
-                    version = p.getVersion();
-                }
-
                 Plugin pp = new Plugin();
                 pp.setGroupId( p.getGroupId() );
                 pp.setArtifactId( p.getArtifactId() );
-                pp.setVersion( version );
+                pp.setVersion( p.getVersion() );
+
                 Artifact artifact = repositorySystem.createPluginArtifact( pp );
 
                 if ( artifact != null )
@@ -1205,7 +1196,9 @@ public class MavenProject
                 }
             }
         }
+
         reportArtifactMap = null;
+
         return reportArtifacts;
     }
 
@@ -1934,6 +1927,11 @@ public class MavenProject
             parentFile = new File( project.getParentFile().getAbsolutePath() );
         }
 
+        if ( project.getPluginArtifacts() != null )
+        {
+            setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts()
) );
+        }
+
         if ( project.getReportArtifacts() != null )
         {
             setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts()
) );



Mime
View raw message