Author: bentmann
Date: Tue Sep 29 09:38:12 2009
New Revision: 819868

URL: http://svn.apache.org/viewvc?rev=819868&view=rev
Log:
o Revised extension caching to be insensitive to POM repos

Added:
    
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
   (with props)
    
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
   (with props)
Modified:
    
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
    
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java
    
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java

Modified: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java?rev=819868&r1=819867&r2=819868&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
 (original)
+++ 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
 Tue Sep 29 09:38:12 2009
@@ -19,18 +19,13 @@
  * under the License.
  */
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Exclusion;
-import org.apache.maven.model.Plugin;
 import org.apache.maven.project.ExtensionDescriptor;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
@@ -47,22 +42,19 @@
     private static class CacheKey
     {
 
-        private final Plugin extension;
-
-        private final List<ArtifactRepository> repositories = new 
ArrayList<ArtifactRepository>();
+        private final List<File> files;
 
         private final int hashCode;
 
-        public CacheKey( Plugin extension, RepositoryRequest repositoryRequest 
)
+        public CacheKey( List<? extends Artifact> extensionArtifacts )
         {
-            this.extension = extension.clone();
-            this.repositories.add( repositoryRequest.getLocalRepository() );
-            this.repositories.addAll( 
repositoryRequest.getRemoteRepositories() );
-
-            int hash = 17;
-            hash = hash * 31 + extensionHashCode( extension );
-            hash = hash * 31 + repositories.hashCode();
-            this.hashCode = hash;
+            this.files = new ArrayList<File>( extensionArtifacts.size() );
+            for ( Artifact artifact : extensionArtifacts )
+            {
+                files.add( artifact.getFile() );
+            }
+
+            this.hashCode = files.hashCode();
         }
 
         @Override
@@ -86,35 +78,38 @@
 
             CacheKey other = (CacheKey) o;
 
-            return extensionEquals( extension, other.extension ) && eq( 
repositories, other.repositories );
+            return files.equals( other.files );
         }
 
     }
 
     private final Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, 
CacheRecord>();
 
-    public CacheRecord get( Plugin extension, RepositoryRequest 
repositoryRequest )
+    public CacheRecord get( List<? extends Artifact> extensionArtifacts )
     {
-        return cache.get( new CacheKey( extension, repositoryRequest ) );
+        return cache.get( new CacheKey( extensionArtifacts ) );
     }
 
-    public void put( Plugin extension, RepositoryRequest repositoryRequest, 
ClassRealm extensionRealm,
-                     List<Artifact> extensionArtifacts, ExtensionDescriptor 
extensionDescriptor )
+    public CacheRecord put( List<? extends Artifact> extensionArtifacts, 
ClassRealm extensionRealm,
+                            ExtensionDescriptor extensionDescriptor )
     {
-        if ( extensionRealm == null || extensionArtifacts == null )
+        if ( extensionRealm == null )
         {
             throw new NullPointerException();
         }
 
-        CacheKey key = new CacheKey( extension, repositoryRequest );
+        CacheKey key = new CacheKey( extensionArtifacts );
 
         if ( cache.containsKey( key ) )
         {
-            throw new IllegalStateException( "Duplicate extension realm for 
extension " + extension.getId() );
+            throw new IllegalStateException( "Duplicate extension realm for 
extension " + extensionArtifacts );
         }
 
-        CacheRecord record = new CacheRecord( extensionRealm, 
extensionArtifacts, extensionDescriptor );
+        CacheRecord record = new CacheRecord( extensionRealm, 
extensionDescriptor );
+
         cache.put( key, record );
+
+        return record;
     }
 
     public void flush()
@@ -122,108 +117,7 @@
         cache.clear();
     }
 
-    protected static int extensionHashCode( Plugin extension )
-    {
-        int hash = 17;
-
-        hash = hash * 31 + extension.getGroupId().hashCode();
-        hash = hash * 31 + extension.getArtifactId().hashCode();
-        hash = hash * 31 + extension.getVersion().hashCode();
-
-        for ( Dependency dependency : extension.getDependencies() )
-        {
-            hash = hash * 31 + dependency.getGroupId().hashCode();
-            hash = hash * 31 + dependency.getArtifactId().hashCode();
-            hash = hash * 31 + dependency.getVersion().hashCode();
-            hash = hash * 31 + dependency.getType().hashCode();
-            hash = hash * 31 + ( dependency.getClassifier() != null ? 
dependency.getClassifier().hashCode() : 0 );
-            hash = hash * 31 + ( dependency.getScope() != null ? 
dependency.getScope().hashCode() : 0 );
-
-            for ( Exclusion exclusion : dependency.getExclusions() )
-            {
-                hash = hash * 31 + exclusion.getGroupId().hashCode();
-                hash = hash * 31 + exclusion.getArtifactId().hashCode();
-            }
-        }
-
-        return hash;
-    }
-
-    private static boolean extensionEquals( Plugin a, Plugin b )
-    {
-        return eq( a.getGroupId(), b.getGroupId() ) //
-            && eq( a.getArtifactId(), b.getArtifactId() ) //
-            && eq( a.getVersion(), b.getVersion() ) // 
-            && a.isExtensions() == b.isExtensions() //
-            && dependenciesEquals( a.getDependencies(), b.getDependencies() );
-    }
-
-    private static boolean dependenciesEquals( List<Dependency> a, 
List<Dependency> b )
-    {
-        if ( a.size() != b.size() )
-        {
-            return false;
-        }
-
-        Iterator<Dependency> aI = a.iterator();
-        Iterator<Dependency> bI = b.iterator();
-
-        while ( aI.hasNext() )
-        {
-            Dependency aD = aI.next();
-            Dependency bD = bI.next();
-
-            boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
-                && eq( aD.getArtifactId(), bD.getArtifactId() ) //
-                && eq( aD.getVersion(), bD.getVersion() ) // 
-                && eq( aD.getType(), bD.getType() ) //
-                && eq( aD.getClassifier(), bD.getClassifier() ) //
-                && eq( aD.getScope(), bD.getScope() );
-
-            r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() );
-
-            if ( !r )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    private static boolean exclusionsEquals( List<Exclusion> a, 
List<Exclusion> b )
-    {
-        if ( a.size() != b.size() )
-        {
-            return false;
-        }
-
-        Iterator<Exclusion> aI = a.iterator();
-        Iterator<Exclusion> bI = b.iterator();
-
-        while ( aI.hasNext() )
-        {
-            Exclusion aD = aI.next();
-            Exclusion bD = bI.next();
-
-            boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
-                && eq( aD.getArtifactId(), bD.getArtifactId() );
-
-            if ( !r )
-            {
-                return false;
-            }
-        }
-
-        return true;
-    }
-
-    private static <T> boolean eq( T s1, T s2 )
-    {
-        return s1 != null ? s1.equals( s2 ) : s2 == null;
-    }
-
-    public void register( MavenProject project, ClassRealm extensionRealm )
+    public void register( MavenProject project, CacheRecord record )
     {
         // default cache does not track extension usage
     }

Added: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java?rev=819868&view=auto
==============================================================================
--- 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
 (added)
+++ 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
 Tue Sep 29 09:38:12 2009
@@ -0,0 +1,240 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.RepositoryRequest;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Exclusion;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.component.annotations.Component;
+
+/**
+ * @author Igor Fedorenko
+ * @author Benjamin Bentmann
+ */
+...@component( role = PluginArtifactsCache.class )
+public class DefaultPluginArtifactsCache
+    implements PluginArtifactsCache
+{
+
+    private static class CacheKey
+    {
+
+        private final Plugin plugin;
+
+        private final List<ArtifactRepository> repositories = new 
ArrayList<ArtifactRepository>();
+
+        private final ArtifactFilter extensionArtifactFilter;
+
+        private final int hashCode;
+
+        public CacheKey( Plugin plugin, RepositoryRequest repositoryRequest, 
ArtifactFilter extensionArtifactFilter )
+        {
+            this.plugin = plugin.clone();
+            this.repositories.add( repositoryRequest.getLocalRepository() );
+            this.repositories.addAll( 
repositoryRequest.getRemoteRepositories() );
+            this.extensionArtifactFilter = extensionArtifactFilter;
+
+            int hash = 17;
+            hash = hash * 31 + pluginHashCode( plugin );
+            hash = hash * 31 + repositories.hashCode();
+            hash = hash * 31 + ( extensionArtifactFilter != null ? 
extensionArtifactFilter.hashCode() : 0 );
+            this.hashCode = hash;
+        }
+
+        @Override
+        public int hashCode()
+        {
+            return hashCode;
+        }
+
+        @Override
+        public boolean equals( Object o )
+        {
+            if ( o == this )
+            {
+                return true;
+            }
+
+            if ( !( o instanceof CacheKey ) )
+            {
+                return false;
+            }
+
+            CacheKey other = (CacheKey) o;
+
+            return pluginEquals( plugin, other.plugin ) && eq( repositories, 
other.repositories )
+                && eq( extensionArtifactFilter, other.extensionArtifactFilter 
);
+        }
+
+    }
+
+    protected final Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, 
CacheRecord>();
+
+    public CacheRecord get( Plugin plugin, RepositoryRequest 
repositoryRequest, ArtifactFilter extensionArtifactFilter )
+    {
+        return cache.get( new CacheKey( plugin, repositoryRequest, 
extensionArtifactFilter ) );
+    }
+
+    public CacheRecord put( Plugin plugin, RepositoryRequest 
repositoryRequest, ArtifactFilter extensionArtifactFilter,
+                            List<Artifact> pluginArtifacts )
+    {
+        if ( pluginArtifacts == null )
+        {
+            throw new NullPointerException();
+        }
+
+        CacheKey key = new CacheKey( plugin, repositoryRequest, 
extensionArtifactFilter );
+
+        if ( cache.containsKey( key ) )
+        {
+            throw new IllegalStateException( "Duplicate artifact resolution 
result for plugin " + plugin.getId() );
+        }
+
+        CacheRecord record =
+            new CacheRecord( Collections.unmodifiableList( new 
ArrayList<Artifact>( pluginArtifacts ) ) );
+
+        cache.put( key, record );
+
+        return record;
+    }
+
+    public void flush()
+    {
+        cache.clear();
+    }
+
+    protected static int pluginHashCode( Plugin plugin )
+    {
+        int hash = 17;
+
+        hash = hash * 31 + plugin.getGroupId().hashCode();
+        hash = hash * 31 + plugin.getArtifactId().hashCode();
+        hash = hash * 31 + plugin.getVersion().hashCode();
+
+        for ( Dependency dependency : plugin.getDependencies() )
+        {
+            hash = hash * 31 + dependency.getGroupId().hashCode();
+            hash = hash * 31 + dependency.getArtifactId().hashCode();
+            hash = hash * 31 + dependency.getVersion().hashCode();
+            hash = hash * 31 + dependency.getType().hashCode();
+            hash = hash * 31 + ( dependency.getClassifier() != null ? 
dependency.getClassifier().hashCode() : 0 );
+            hash = hash * 31 + ( dependency.getScope() != null ? 
dependency.getScope().hashCode() : 0 );
+
+            for ( Exclusion exclusion : dependency.getExclusions() )
+            {
+                hash = hash * 31 + exclusion.getGroupId().hashCode();
+                hash = hash * 31 + exclusion.getArtifactId().hashCode();
+            }
+        }
+
+        return hash;
+    }
+
+    protected static boolean pluginEquals( Plugin a, Plugin b )
+    {
+        return eq( a.getGroupId(), b.getGroupId() ) //
+            && eq( a.getArtifactId(), b.getArtifactId() ) //
+            && eq( a.getVersion(), b.getVersion() ) // 
+            && dependenciesEquals( a.getDependencies(), b.getDependencies() );
+    }
+
+    private static boolean dependenciesEquals( List<Dependency> a, 
List<Dependency> b )
+    {
+        if ( a.size() != b.size() )
+        {
+            return false;
+        }
+
+        Iterator<Dependency> aI = a.iterator();
+        Iterator<Dependency> bI = b.iterator();
+
+        while ( aI.hasNext() )
+        {
+            Dependency aD = aI.next();
+            Dependency bD = bI.next();
+
+            boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
+                && eq( aD.getArtifactId(), bD.getArtifactId() ) //
+                && eq( aD.getVersion(), bD.getVersion() ) // 
+                && eq( aD.getType(), bD.getType() ) //
+                && eq( aD.getClassifier(), bD.getClassifier() ) //
+                && eq( aD.getScope(), bD.getScope() );
+
+            r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() );
+
+            if ( !r )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private static boolean exclusionsEquals( List<Exclusion> a, 
List<Exclusion> b )
+    {
+        if ( a.size() != b.size() )
+        {
+            return false;
+        }
+
+        Iterator<Exclusion> aI = a.iterator();
+        Iterator<Exclusion> bI = b.iterator();
+
+        while ( aI.hasNext() )
+        {
+            Exclusion aD = aI.next();
+            Exclusion bD = bI.next();
+
+            boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
+                && eq( aD.getArtifactId(), bD.getArtifactId() );
+
+            if ( !r )
+            {
+                return false;
+            }
+        }
+
+        return true;
+    }
+
+    private static <T> boolean eq( T s1, T s2 )
+    {
+        return s1 != null ? s1.equals( s2 ) : s2 == null;
+    }
+
+    public void register( MavenProject project, CacheRecord record )
+    {
+        // default cache does not track record usage
+    }
+
+}

Propchange: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java?rev=819868&r1=819867&r2=819868&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java
 (original)
+++ 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java
 Tue Sep 29 09:38:12 2009
@@ -22,8 +22,6 @@
 import java.util.List;
 
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.model.Plugin;
 import org.apache.maven.project.ExtensionDescriptor;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.classworlds.realm.ClassRealm;
@@ -44,34 +42,31 @@
 
         public final ClassRealm realm;
 
-        public final List<Artifact> artifacts;
-
         public final ExtensionDescriptor desciptor;
 
-        public CacheRecord( ClassRealm realm, List<Artifact> artifacts, 
ExtensionDescriptor descriptor )
+        public CacheRecord( ClassRealm realm, ExtensionDescriptor descriptor )
         {
             this.realm = realm;
-            this.artifacts = artifacts;
             this.desciptor = descriptor;
         }
 
     }
 
-    CacheRecord get( Plugin extension, RepositoryRequest repositoryRequest );
+    CacheRecord get( List<? extends Artifact> extensionArtifacts );
 
-    void put( Plugin extension, RepositoryRequest repositoryRequest, 
ClassRealm extensionRealm,
-              List<Artifact> extensionArtifacts, ExtensionDescriptor 
extensionDescriptor );
+    CacheRecord put( List<? extends Artifact> extensionArtifacts, ClassRealm 
extensionRealm,
+                     ExtensionDescriptor extensionDescriptor );
 
     void flush();
 
     /**
-     * Registers the specified extension realm for usage with the given 
project. Integrators can use the information
-     * collected from this method in combination with a custom cache 
implementation to dispose unused extension realms
-     * from the cache.
+     * Registers the specified cache record for usage with the given project. 
Integrators can use the information
+     * collected from this method in combination with a custom cache 
implementation to dispose unused records from the
+     * cache.
      * 
-     * @param project The project that employs the extension realm, must not 
be {...@code null}.
-     * @param extensionRealm The extension realm being used for the project, 
must not be {...@code null}.
+     * @param project The project that employs the plugin realm, must not be 
{...@code null}.
+     * @param record The cache record being used for the project, must not be 
{...@code null}.
      */
-    void register( MavenProject project, ClassRealm extensionRealm );
+    void register( MavenProject project, CacheRecord record );
 
 }

Added: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java?rev=819868&view=auto
==============================================================================
--- 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
 (added)
+++ 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
 Tue Sep 29 09:38:12 2009
@@ -0,0 +1,70 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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 java.util.List;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.RepositoryRequest;
+import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
+import org.apache.maven.model.Plugin;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Caches plugin artifacts. <strong>Warning:</strong> This is an internal 
utility interface that is only public for
+ * technical reasons, it is not part of the public API. In particular, this 
interface can be changed or deleted without
+ * prior notice.
+ * 
+ * @author Igor Fedorenko
+ * @author Benjamin Bentmann
+ */
+public interface PluginArtifactsCache
+{
+
+    public static class CacheRecord
+    {
+
+        public final List<Artifact> artifacts;
+
+        public CacheRecord( List<Artifact> artifacts )
+        {
+            this.artifacts = artifacts;
+        }
+
+    }
+
+    CacheRecord get( Plugin plugin, RepositoryRequest repositoryRequest, 
ArtifactFilter extensionArtifactFilter );
+
+    CacheRecord put( Plugin plugin, RepositoryRequest repositoryRequest, 
ArtifactFilter extensionArtifactFilter,
+                     List<Artifact> pluginArtifacts );
+
+    void flush();
+
+    /**
+     * Registers the specified cache record for usage with the given project. 
Integrators can use the information
+     * collected from this method in combination with a custom cache 
implementation to dispose unused records from the
+     * cache.
+     * 
+     * @param project The project that employs the plugin realm, must not be 
{...@code null}.
+     * @param record The cache record being used for the project, must not be 
{...@code null}.
+     */
+    void register( MavenProject project, CacheRecord record );
+
+}

Propchange: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
URL: 
http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java?rev=819868&r1=819867&r2=819868&view=diff
==============================================================================
--- 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
 (original)
+++ 
maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultProjectBuildingHelper.java
 Tue Sep 29 09:38:12 2009
@@ -49,6 +49,7 @@
 import org.apache.maven.model.Plugin;
 import org.apache.maven.model.Repository;
 import org.apache.maven.plugin.ExtensionRealmCache;
+import org.apache.maven.plugin.PluginArtifactsCache;
 import org.apache.maven.plugin.version.DefaultPluginVersionRequest;
 import org.apache.maven.plugin.version.PluginVersionRequest;
 import org.apache.maven.plugin.version.PluginVersionResolutionException;
@@ -82,6 +83,9 @@
     private ClassRealmManager classRealmManager;
 
     @Requirement
+    private PluginArtifactsCache pluginArtifactsCache;
+
+    @Requirement
     private ExtensionRealmCache extensionRealmCache;
 
     @Requirement
@@ -180,22 +184,36 @@
                 plugin.setVersion( pluginVersionResolver.resolve( 
versionRequest ).getVersion() );
             }
 
-            ClassRealm extensionRealm;
             List<Artifact> artifacts;
-            ExtensionDescriptor extensionDescriptor = null;
 
-            ExtensionRealmCache.CacheRecord record = extensionRealmCache.get( 
plugin, repositoryRequest );
+            PluginArtifactsCache.CacheRecord recordArtifacts =
+                pluginArtifactsCache.get( plugin, repositoryRequest, null );
 
-            if ( record != null )
+            if ( recordArtifacts != null )
             {
-                extensionRealm = record.realm;
-                artifacts = record.artifacts;
-                extensionDescriptor = record.desciptor;
+                artifacts = recordArtifacts.artifacts;
             }
             else
             {
                 artifacts = resolveExtensionArtifacts( plugin, 
repositoryRequest );
 
+                recordArtifacts = pluginArtifactsCache.put( plugin, 
repositoryRequest, null, artifacts );
+            }
+
+            pluginArtifactsCache.register( project, recordArtifacts );
+
+            ClassRealm extensionRealm;
+            ExtensionDescriptor extensionDescriptor = null;
+
+            ExtensionRealmCache.CacheRecord recordRealm = 
extensionRealmCache.get( artifacts );
+
+            if ( recordRealm != null )
+            {
+                extensionRealm = recordRealm.realm;
+                extensionDescriptor = recordRealm.desciptor;
+            }
+            else
+            {
                 extensionRealm = classRealmManager.createExtensionRealm( 
plugin );
 
                 if ( logger.isDebugEnabled() )
@@ -258,10 +276,10 @@
                     }
                 }
 
-                extensionRealmCache.put( plugin, repositoryRequest, 
extensionRealm, artifacts, extensionDescriptor );
+                recordRealm = extensionRealmCache.put( artifacts, 
extensionRealm, extensionDescriptor );
             }
 
-            extensionRealmCache.register( project, extensionRealm );
+            extensionRealmCache.register( project, recordRealm );
 
             extensionRealms.add( extensionRealm );
             if ( extensionDescriptor != null )


Reply via email to