MNG-5003 populate mojo descriptor with cached plugin realm

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1067279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Igor Fedorenko 2011-02-04 20:44:55 +00:00
parent 1c6745c2a8
commit a7d9b689fa
2 changed files with 45 additions and 0 deletions

View File

@ -311,6 +311,10 @@ public class DefaultMavenPluginManager
{ {
pluginDescriptor.setClassRealm( cacheRecord.realm ); pluginDescriptor.setClassRealm( cacheRecord.realm );
pluginDescriptor.setArtifacts( new ArrayList<Artifact>( cacheRecord.artifacts ) ); pluginDescriptor.setArtifacts( new ArrayList<Artifact>( cacheRecord.artifacts ) );
for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
{
componentDescriptor.setRealm( cacheRecord.realm );
}
} }
else else
{ {

View File

@ -31,6 +31,7 @@ import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
public class PluginManagerTest public class PluginManagerTest
extends AbstractCoreMavenComponentTestCase extends AbstractCoreMavenComponentTestCase
@ -273,4 +274,44 @@ public class PluginManagerTest
assertEquals( artifactId, pd.getArtifactId() ); assertEquals( artifactId, pd.getArtifactId() );
assertEquals( version, pd.getVersion() ); assertEquals( version, pd.getVersion() );
} }
public void testPluginRealmCache()
throws Exception
{
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
repositoryRequest.setLocalRepository( getLocalRepository() );
repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() );
// prime realm cache
MavenSession session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) );
MavenProject project = session.getCurrentProject();
Plugin plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" );
PluginDescriptor pluginDescriptor =
pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(),
session.getRepositorySession() );
pluginManager.getPluginRealm( session, pluginDescriptor );
for ( ComponentDescriptor<?> descriptor : pluginDescriptor.getComponents() )
{
assertNotNull( descriptor.getRealm() );
assertNotNull( descriptor.getImplementationClass() );
}
// reload plugin realm from cache
session = createMavenSession( getProject( "project-contributing-system-scope-plugin-dep" ) );
project = session.getCurrentProject();
plugin = project.getPlugin( "org.apache.maven.its.plugins:maven-it-plugin" );
pluginDescriptor =
pluginManager.loadPlugin( plugin, session.getCurrentProject().getRemotePluginRepositories(),
session.getRepositorySession() );
pluginManager.getPluginRealm( session, pluginDescriptor );
for ( ComponentDescriptor<?> descriptor : pluginDescriptor.getComponents() )
{
assertNotNull( descriptor.getRealm() );
assertNotNull( descriptor.getImplementationClass() );
}
}
} }