Revert "[MNG-6867] extract methods, apply SLA"

This reverts commit c423a090e3.
This commit is contained in:
Lewinski, Arne 2020-02-16 14:54:11 +01:00 committed by Sylwester Lachiewicz
parent c423a090e3
commit d127bce8c9
1 changed files with 26 additions and 42 deletions

View File

@ -328,15 +328,37 @@ public class DefaultMavenPluginManager
if ( plugin.isExtensions() )
{
setupPluginDescriptor( pluginDescriptor, session );
ExtensionRealmCache.CacheRecord extensionRecord;
try
{
RepositorySystemSession repositorySession = session.getRepositorySession();
extensionRecord = setupExtensionsRealm( project, plugin, repositorySession );
}
catch ( PluginManagerException e )
{
// extensions realm is expected to be fully setup at this point
// any exception means a problem in maven code, not a user error
throw new IllegalStateException( e );
}
ClassRealm pluginRealm = extensionRecord.getRealm();
List<Artifact> pluginArtifacts = extensionRecord.getArtifacts();
for ( ComponentDescriptor<?> componentDescriptor : pluginDescriptor.getComponents() )
{
componentDescriptor.setRealm( pluginRealm );
}
pluginDescriptor.setClassRealm( pluginRealm );
pluginDescriptor.setArtifacts( pluginArtifacts );
}
else
{
Map<String, ClassLoader> foreignImports = calcImports( project, parent, imports );
PluginRealmCache.Key cacheKey =
pluginRealmCache.createKey( plugin, parent, foreignImports, filter,
project.getRemotePluginRepositories(), session.getRepositorySession() );
PluginRealmCache.Key cacheKey = pluginRealmCache.createKey( plugin, parent, foreignImports, filter,
project.getRemotePluginRepositories(),
session.getRepositorySession() );
PluginRealmCache.CacheRecord cacheRecord = pluginRealmCache.get( cacheKey );
@ -361,44 +383,6 @@ public class DefaultMavenPluginManager
}
}
private void setupPluginDescriptor( PluginDescriptor pluginDescriptor, MavenSession session )
{
setupPluginDescriptor( pluginDescriptor,
setupExtensionsRealmInternal( session.getCurrentProject(), pluginDescriptor.getPlugin(),
session.getRepositorySession() ) );
}
private void setupPluginDescriptor( PluginDescriptor pluginDescriptor,
ExtensionRealmCache.CacheRecord extensionRecord )
{
setupComponentDescriptors( extensionRecord, pluginDescriptor.getComponents() );
pluginDescriptor.setClassRealm( extensionRecord.getRealm() );
pluginDescriptor.setArtifacts( extensionRecord.getArtifacts() );
}
private void setupComponentDescriptors( ExtensionRealmCache.CacheRecord extensionRecord,
List<ComponentDescriptor<?>> components )
{
components.stream().forEach( descriptor -> descriptor.setRealm( extensionRecord.getRealm() ) );
}
/**
* For internal usage. It is assumed that the prerequisites are met so a setup of the extensions realm can be
* processed without any error. Any exception thrown indicates a programming error, not a user error!
*/
private ExtensionRealmCache.CacheRecord setupExtensionsRealmInternal( MavenProject project, Plugin plugin,
RepositorySystemSession repositorySystemSession )
{
try
{
return setupExtensionsRealm( project, plugin, repositorySystemSession );
}
catch ( PluginManagerException e )
{
throw new IllegalStateException( e );
}
}
private void createPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,
Map<String, ClassLoader> foreignImports, DependencyFilter filter )
throws PluginResolutionException, PluginContainerException