From 586709aadd290ed67e5f80e00a8dc555afb7f912 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sat, 15 Jan 2011 05:25:59 +0000 Subject: [PATCH] [MNG-4973] [regression] Build extensions are invisible to plugins in multi module build git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1059266 13f79535-47bb-0310-9956-ffa450edef68 --- .../maven/plugin/DefaultPluginRealmCache.java | 15 ++++++++------- .../org/apache/maven/plugin/PluginRealmCache.java | 6 ++++-- .../internal/DefaultMavenPluginManager.java | 10 +++++----- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java index f1b46bb9bf..896236741e 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java @@ -58,13 +58,13 @@ public class DefaultPluginRealmCache private final ClassLoader parentRealm; - private final List parentImports; + private final Map foreignImports; private final DependencyFilter filter; private final int hashCode; - public CacheKey( Plugin plugin, ClassLoader parentRealm, List parentImports, + public CacheKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) { @@ -84,7 +84,8 @@ public class DefaultPluginRealmCache } } this.parentRealm = parentRealm; - this.parentImports = ( parentImports != null ) ? parentImports : Collections. emptyList(); + this.foreignImports = + ( foreignImports != null ) ? foreignImports : Collections. emptyMap(); this.filter = dependencyFilter; int hash = 17; @@ -93,7 +94,7 @@ public class DefaultPluginRealmCache hash = hash * 31 + hash( localRepo ); hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories ); hash = hash * 31 + hash( parentRealm ); - hash = hash * 31 + this.parentImports.hashCode(); + hash = hash * 31 + this.foreignImports.hashCode(); hash = hash * 31 + hash( dependencyFilter ); this.hashCode = hash; } @@ -133,7 +134,7 @@ public class DefaultPluginRealmCache return parentRealm == that.parentRealm && CacheUtils.pluginEquals( plugin, that.plugin ) && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( this.repositories, that.repositories ) && eq( filter, that.filter ) - && eq( parentImports, that.parentImports ); + && eq( foreignImports, that.foreignImports ); } private static boolean eq( T s1, T s2 ) @@ -145,11 +146,11 @@ public class DefaultPluginRealmCache protected final Map cache = new ConcurrentHashMap(); - public Key createKey( Plugin plugin, ClassLoader parentRealm, List parentImports, + public Key createKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ) { - return new CacheKey( plugin, parentRealm, parentImports, dependencyFilter, repositories, session ); + return new CacheKey( plugin, parentRealm, foreignImports, dependencyFilter, repositories, session ); } public CacheRecord get( Key key ) diff --git a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java b/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java index faf89029c0..684208186e 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/PluginRealmCache.java @@ -20,6 +20,7 @@ package org.apache.maven.plugin; */ import java.util.List; +import java.util.Map; import org.apache.maven.artifact.Artifact; import org.apache.maven.model.Plugin; @@ -61,8 +62,9 @@ public interface PluginRealmCache // marker interface for cache keys } - Key createKey( Plugin plugin, ClassLoader parentRealm, List parentImports, - DependencyFilter dependencyFilter, List repositories, RepositorySystemSession session ); + Key createKey( Plugin plugin, ClassLoader parentRealm, Map foreignImports, + DependencyFilter dependencyFilter, List repositories, + RepositorySystemSession session ); CacheRecord get( Key key ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java index 33e7758c1d..0c541b1d9d 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/internal/DefaultMavenPluginManager.java @@ -299,8 +299,10 @@ public class DefaultMavenPluginManager MavenProject project = session.getCurrentProject(); + Map foreignImports = calcImports( project, parent, imports ); + PluginRealmCache.Key cacheKey = - pluginRealmCache.createKey( plugin, parent, imports, filter, project.getRemotePluginRepositories(), + pluginRealmCache.createKey( plugin, parent, foreignImports, filter, project.getRemotePluginRepositories(), session.getRepositorySession() ); PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey ); @@ -312,7 +314,7 @@ public class DefaultMavenPluginManager } else { - createPluginRealm( pluginDescriptor, session, parent, imports, filter ); + createPluginRealm( pluginDescriptor, session, parent, foreignImports, filter ); cacheRecord = pluginRealmCache.put( cacheKey, pluginDescriptor.getClassRealm(), pluginDescriptor.getArtifacts() ); @@ -322,7 +324,7 @@ public class DefaultMavenPluginManager } private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, - List imports, DependencyFilter filter ) + Map foreignImports, DependencyFilter filter ) throws PluginResolutionException, PluginContainerException { Plugin plugin = pluginDescriptor.getPlugin(); @@ -365,8 +367,6 @@ public class DefaultMavenPluginManager List pluginArtifacts = nlg.getArtifacts( true ); - Map foreignImports = calcImports( project, parent, imports ); - ClassRealm pluginRealm = classRealmManager.createPluginRealm( plugin, parent, null, foreignImports, pluginArtifacts );