mirror of https://github.com/apache/maven.git
MNG-4916 cache extension plugin resolution errors
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1038917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c3abfba3b
commit
e260076924
|
@ -142,8 +142,16 @@ public class DefaultPluginArtifactsCache
|
|||
}
|
||||
|
||||
public CacheRecord get( Key key )
|
||||
throws PluginResolutionException
|
||||
{
|
||||
return cache.get( key );
|
||||
CacheRecord cacheRecord = cache.get( key );
|
||||
|
||||
if ( cacheRecord != null && cacheRecord.exception != null )
|
||||
{
|
||||
throw cacheRecord.exception;
|
||||
}
|
||||
|
||||
return cacheRecord;
|
||||
}
|
||||
|
||||
public CacheRecord put( Key key, List<Artifact> pluginArtifacts )
|
||||
|
@ -153,13 +161,34 @@ public class DefaultPluginArtifactsCache
|
|||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
assertUniqueKey( key );
|
||||
|
||||
CacheRecord record =
|
||||
new CacheRecord( Collections.unmodifiableList( new ArrayList<Artifact>( pluginArtifacts ) ) );
|
||||
|
||||
cache.put( key, record );
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
protected void assertUniqueKey( Key key )
|
||||
{
|
||||
if ( cache.containsKey( key ) )
|
||||
{
|
||||
throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + key );
|
||||
}
|
||||
}
|
||||
|
||||
CacheRecord record =
|
||||
new CacheRecord( Collections.unmodifiableList( new ArrayList<Artifact>( pluginArtifacts ) ) );
|
||||
public CacheRecord put( Key key, PluginResolutionException exception )
|
||||
{
|
||||
if ( exception == null )
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
assertUniqueKey( key );
|
||||
|
||||
CacheRecord record = new CacheRecord( exception );
|
||||
|
||||
cache.put( key, record );
|
||||
|
||||
|
|
|
@ -52,20 +52,30 @@ public interface PluginArtifactsCache
|
|||
|
||||
public final List<Artifact> artifacts;
|
||||
|
||||
public final PluginResolutionException exception;
|
||||
|
||||
public CacheRecord( List<Artifact> artifacts )
|
||||
{
|
||||
this.artifacts = artifacts;
|
||||
this.exception = null;
|
||||
}
|
||||
|
||||
public CacheRecord( PluginResolutionException exception )
|
||||
{
|
||||
this.artifacts = null;
|
||||
this.exception = exception;
|
||||
}
|
||||
}
|
||||
|
||||
Key createKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories,
|
||||
RepositorySystemSession session );
|
||||
|
||||
CacheRecord get( Key key );
|
||||
CacheRecord get( Key key ) throws PluginResolutionException;
|
||||
|
||||
CacheRecord put( Key key, List<Artifact> pluginArtifacts );
|
||||
|
||||
CacheRecord put( Key key, PluginResolutionException e );
|
||||
|
||||
void flush();
|
||||
|
||||
/**
|
||||
|
|
|
@ -231,11 +231,22 @@ public class DefaultProjectBuildingHelper
|
|||
artifacts = recordArtifacts.artifacts;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
artifacts = resolveExtensionArtifacts( plugin, project.getRemotePluginRepositories(), request );
|
||||
|
||||
recordArtifacts = pluginArtifactsCache.put( cacheKey, artifacts );
|
||||
}
|
||||
catch ( PluginResolutionException e )
|
||||
{
|
||||
pluginArtifactsCache.put( cacheKey, e );
|
||||
|
||||
pluginArtifactsCache.register( project, recordArtifacts );
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
pluginArtifactsCache.register( project, recordArtifacts );
|
||||
|
||||
|
|
Loading…
Reference in New Issue