[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
This commit is contained in:
Benjamin Bentmann 2011-01-15 05:25:59 +00:00
parent ba01f7b3a3
commit 586709aadd
3 changed files with 17 additions and 14 deletions

View File

@ -58,13 +58,13 @@ public class DefaultPluginRealmCache
private final ClassLoader parentRealm;
private final List<String> parentImports;
private final Map<String, ClassLoader> foreignImports;
private final DependencyFilter filter;
private final int hashCode;
public CacheKey( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
public CacheKey( Plugin plugin, ClassLoader parentRealm, Map<String, ClassLoader> foreignImports,
DependencyFilter dependencyFilter, List<RemoteRepository> repositories,
RepositorySystemSession session )
{
@ -84,7 +84,8 @@ public class DefaultPluginRealmCache
}
}
this.parentRealm = parentRealm;
this.parentImports = ( parentImports != null ) ? parentImports : Collections.<String> emptyList();
this.foreignImports =
( foreignImports != null ) ? foreignImports : Collections.<String, ClassLoader> 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 <T> boolean eq( T s1, T s2 )
@ -145,11 +146,11 @@ public class DefaultPluginRealmCache
protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<Key, CacheRecord>();
public Key createKey( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
public Key createKey( Plugin plugin, ClassLoader parentRealm, Map<String, ClassLoader> foreignImports,
DependencyFilter dependencyFilter, List<RemoteRepository> 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 )

View File

@ -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<String> parentImports,
DependencyFilter dependencyFilter, List<RemoteRepository> repositories, RepositorySystemSession session );
Key createKey( Plugin plugin, ClassLoader parentRealm, Map<String, ClassLoader> foreignImports,
DependencyFilter dependencyFilter, List<RemoteRepository> repositories,
RepositorySystemSession session );
CacheRecord get( Key key );

View File

@ -299,8 +299,10 @@ public class DefaultMavenPluginManager
MavenProject project = session.getCurrentProject();
Map<String, ClassLoader> 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<String> imports, DependencyFilter filter )
Map<String, ClassLoader> foreignImports, DependencyFilter filter )
throws PluginResolutionException, PluginContainerException
{
Plugin plugin = pluginDescriptor.getPlugin();
@ -365,8 +367,6 @@ public class DefaultMavenPluginManager
List<org.sonatype.aether.artifact.Artifact> pluginArtifacts = nlg.getArtifacts( true );
Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );
ClassRealm pluginRealm =
classRealmManager.createPluginRealm( plugin, parent, null, foreignImports, pluginArtifacts );