mirror of https://github.com/apache/maven.git
[MNG-3281] Revisit backwards compat of extensions (IT 0114)
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@815761 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6b2adee21f
commit
b98795ecb9
|
@ -154,10 +154,11 @@ public class DefaultBuildPluginManager
|
|||
|
||||
Plugin plugin = pluginDescriptor.getPlugin();
|
||||
|
||||
MavenProject project = session.getCurrentProject();
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
List<ArtifactRepository> remoteRepositories = session.getCurrentProject().getPluginArtifactRepositories();
|
||||
List<ArtifactRepository> remoteRepositories = project.getPluginArtifactRepositories();
|
||||
|
||||
PluginCache.CacheRecord cacheRecord = pluginCache.get( plugin, localRepository, remoteRepositories );
|
||||
PluginCache.CacheRecord cacheRecord = pluginCache.get( plugin, project, localRepository, remoteRepositories );
|
||||
|
||||
if ( cacheRecord != null )
|
||||
{
|
||||
|
@ -168,14 +169,14 @@ public class DefaultBuildPluginManager
|
|||
{
|
||||
try
|
||||
{
|
||||
mavenPluginManager.setupPluginRealm( pluginDescriptor, session, null, null );
|
||||
mavenPluginManager.setupPluginRealm( pluginDescriptor, session, project.getClassRealm(), null );
|
||||
}
|
||||
catch ( PluginResolutionException e )
|
||||
{
|
||||
throw new PluginManagerException( plugin, e.getMessage(), e );
|
||||
}
|
||||
|
||||
pluginCache.put( plugin, localRepository, remoteRepositories, pluginDescriptor.getClassRealm(),
|
||||
pluginCache.put( plugin, project, localRepository, remoteRepositories, pluginDescriptor.getClassRealm(),
|
||||
pluginDescriptor.getArtifacts() );
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
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.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
|
@ -47,17 +48,22 @@ public class DefaultPluginCache
|
|||
|
||||
private final List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
|
||||
|
||||
private final ClassRealm projectRealm;
|
||||
|
||||
private final int hashCode;
|
||||
|
||||
public CacheKey( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
public CacheKey( Plugin plugin, MavenProject project, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
this.plugin = plugin.clone();
|
||||
this.repositories.add( localRepository );
|
||||
this.repositories.addAll( remoteRepositories );
|
||||
this.projectRealm = project.getClassRealm();
|
||||
|
||||
int hash = 17;
|
||||
hash = hash * 31 + pluginHashCode( plugin );
|
||||
hash = hash * 31 + repositories.hashCode();
|
||||
hash = hash * 31 + ( projectRealm != null ? projectRealm.hashCode() : 0 );
|
||||
this.hashCode = hash;
|
||||
}
|
||||
|
||||
|
@ -82,27 +88,28 @@ public class DefaultPluginCache
|
|||
|
||||
CacheKey other = (CacheKey) o;
|
||||
|
||||
return pluginEquals( plugin, other.plugin ) && eq(repositories, other.repositories);
|
||||
return projectRealm == other.projectRealm && pluginEquals( plugin, other.plugin )
|
||||
&& eq( repositories, other.repositories );
|
||||
}
|
||||
}
|
||||
|
||||
protected final Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, CacheRecord>();
|
||||
|
||||
public CacheRecord get( Plugin plugin, ArtifactRepository localRepository,
|
||||
public CacheRecord get( Plugin plugin, MavenProject project, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
{
|
||||
return cache.get( new CacheKey( plugin, localRepository, remoteRepositories ) );
|
||||
return cache.get( new CacheKey( plugin, project, localRepository, remoteRepositories ) );
|
||||
}
|
||||
|
||||
public void put( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
|
||||
ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
|
||||
public void put( Plugin plugin, MavenProject project, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories, ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
|
||||
{
|
||||
if ( pluginRealm == null || pluginArtifacts == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
CacheKey key = new CacheKey( plugin, localRepository, remoteRepositories );
|
||||
CacheKey key = new CacheKey( plugin, project, localRepository, remoteRepositories );
|
||||
|
||||
if ( cache.containsKey( key ) )
|
||||
{
|
||||
|
|
|
@ -116,11 +116,6 @@ public class DefaultPluginDescriptorCache
|
|||
return clones;
|
||||
}
|
||||
|
||||
private static <T> List<T> clone( List<T> original )
|
||||
{
|
||||
return ( original != null ) ? new ArrayList<T>( original ) : null;
|
||||
}
|
||||
|
||||
private static final class CacheKey
|
||||
implements Key
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
|
||||
public interface PluginCache
|
||||
|
@ -41,10 +42,11 @@ public interface PluginCache
|
|||
}
|
||||
}
|
||||
|
||||
CacheRecord get( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories );
|
||||
CacheRecord get( Plugin plugin, MavenProject project, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories );
|
||||
|
||||
void put( Plugin plugin, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories,
|
||||
ClassRealm pluginRealm, List<Artifact> pluginArtifacts );
|
||||
void put( Plugin plugin, MavenProject project, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories, ClassRealm pluginRealm, List<Artifact> pluginArtifacts );
|
||||
|
||||
void flush();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue