mirror of https://github.com/apache/maven.git
MNG-5742 fixed null ComponentDescriptor#realm for extensions plugins
Signed-off-by: Igor Fedorenko <ifedorenko@apache.org>
This commit is contained in:
parent
6f1571a1a6
commit
6ab41ee8d3
|
@ -390,8 +390,6 @@ public class DefaultMavenPluginManager
|
|||
RepositorySystemSession repositorySession = session.getRepositorySession();
|
||||
if ( plugin.isExtensions() )
|
||||
{
|
||||
// TODO discover components in #setupExtensionsRealm
|
||||
|
||||
ExtensionRealmCache.CacheRecord extensionRecord;
|
||||
try
|
||||
{
|
||||
|
@ -406,6 +404,11 @@ public class DefaultMavenPluginManager
|
|||
|
||||
pluginRealm = extensionRecord.realm;
|
||||
pluginArtifacts = extensionRecord.artifacts;
|
||||
|
||||
for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
|
||||
{
|
||||
componentDescriptor.setRealm( pluginRealm );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -877,6 +880,8 @@ public class DefaultMavenPluginManager
|
|||
{
|
||||
ClassRealm extensionRealm = classRealmManager.createExtensionRealm( plugin, toAetherArtifacts( artifacts ) );
|
||||
|
||||
// TODO figure out how to use the same PluginDescriptor when running mojos
|
||||
|
||||
PluginDescriptor pluginDescriptor = null;
|
||||
if ( plugin.isExtensions() && !artifacts.isEmpty() )
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.maven.model.Plugin;
|
|||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.classworlds.realm.ClassRealm;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.ComponentDescriptor;
|
||||
|
||||
|
@ -318,4 +319,24 @@ public class PluginManagerTest
|
|||
assertNotNull( descriptor.getImplementationClass() );
|
||||
}
|
||||
}
|
||||
|
||||
public void testBuildExtensionsPluginLoading()
|
||||
throws Exception
|
||||
{
|
||||
RepositoryRequest repositoryRequest = new DefaultRepositoryRequest();
|
||||
repositoryRequest.setLocalRepository( getLocalRepository() );
|
||||
repositoryRequest.setRemoteRepositories( getPluginArtifactRepositories() );
|
||||
|
||||
// prime realm cache
|
||||
MavenSession session = createMavenSession( getProject( "project-with-build-extensions-plugin" ) );
|
||||
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() );
|
||||
ClassRealm pluginRealm = pluginManager.getPluginRealm( session, pluginDescriptor );
|
||||
|
||||
assertEquals(pluginRealm, pluginDescriptor.getComponents().get(0).getRealm());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.apache.maven.test</groupId>
|
||||
<artifactId>project-with-build-extensions-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.its.plugins</groupId>
|
||||
<artifactId>maven-it-plugin</artifactId>
|
||||
<version>0.1</version>
|
||||
<extensions>true</extensions>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>load</id>
|
||||
<phase>validate</phase>
|
||||
<configuration>
|
||||
<resourcePaths>maven-core-it.properties</resourcePaths>
|
||||
<pluginClassLoaderOutput>target/pcl.properties</pluginClassLoaderOutput>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>load</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
Loading…
Reference in New Issue