@Component(role=MavenPluginManager.class) public class DefaultMavenPluginManager extends java.lang.Object implements MavenPluginManager
Modifier and Type | Field and Description |
---|---|
private PluginDescriptorBuilder |
builder |
private ClassRealmManager |
classRealmManager |
private org.codehaus.plexus.PlexusContainer |
container |
private ExtensionDescriptorBuilder |
extensionDescriptorBuilder |
private ExtensionRealmCache |
extensionRealmCache |
static java.lang.String |
KEY_EXTENSIONS_REALMS
PluginId => ExtensionRealmCache.CacheRecord map MavenProject context value key.
|
private org.codehaus.plexus.logging.Logger |
logger |
private org.codehaus.plexus.logging.LoggerManager |
loggerManager |
private PluginArtifactsCache |
pluginArtifactsCache |
private PluginDependenciesResolver |
pluginDependenciesResolver |
private PluginDescriptorCache |
pluginDescriptorCache |
private PluginRealmCache |
pluginRealmCache |
private PluginVersionResolver |
pluginVersionResolver |
private RuntimeInformation |
runtimeInformation |
Constructor and Description |
---|
DefaultMavenPluginManager() |
Modifier and Type | Method and Description |
---|---|
private java.util.Map<java.lang.String,java.lang.ClassLoader> |
calcImports(MavenProject project,
java.lang.ClassLoader parent,
java.util.List<java.lang.String> imports) |
void |
checkRequiredMavenVersion(PluginDescriptor pluginDescriptor)
Verifies the specified plugin is compatible with the current Maven runtime.
|
private void |
createPluginRealm(PluginDescriptor pluginDescriptor,
MavenSession session,
java.lang.ClassLoader parent,
java.util.Map<java.lang.String,java.lang.ClassLoader> foreignImports,
org.eclipse.aether.graph.DependencyFilter filter) |
private void |
discoverPluginComponents(org.codehaus.plexus.classworlds.realm.ClassRealm pluginRealm,
Plugin plugin,
PluginDescriptor pluginDescriptor) |
private PluginDescriptor |
extractPluginDescriptor(Artifact pluginArtifact,
Plugin plugin) |
<T> T |
getConfiguredMojo(java.lang.Class<T> mojoInterface,
MavenSession session,
MojoExecution mojoExecution)
Looks up the mojo for the specified mojo execution and populates its parameters from the configuration given by
the mojo execution.
|
MojoDescriptor |
getMojoDescriptor(Plugin plugin,
java.lang.String goal,
java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories,
org.eclipse.aether.RepositorySystemSession session)
Retrieves the descriptor for the specified plugin goal from the plugin's main artifact.
|
PluginDescriptor |
getPluginDescriptor(Plugin plugin,
java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories,
org.eclipse.aether.RepositorySystemSession session)
Retrieves the descriptor for the specified plugin from its main artifact.
|
private java.lang.String |
getPluginDescriptorLocation() |
private PluginDescriptor |
parsePluginDescriptor(java.io.InputStream is,
Plugin plugin,
java.lang.String descriptorLocation) |
private void |
populatePluginFields(java.lang.Object mojo,
MojoDescriptor mojoDescriptor,
org.codehaus.plexus.classworlds.realm.ClassRealm pluginRealm,
org.codehaus.plexus.configuration.PlexusConfiguration configuration,
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator) |
void |
releaseMojo(java.lang.Object mojo,
MojoExecution mojoExecution)
Releases the specified mojo back to the container.
|
private java.util.List<Artifact> |
resolveExtensionArtifacts(Plugin extensionPlugin,
java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories,
org.eclipse.aether.RepositorySystemSession session) |
ExtensionRealmCache.CacheRecord |
setupExtensionsRealm(MavenProject project,
Plugin plugin,
org.eclipse.aether.RepositorySystemSession session)
Sets up class realm for the specified build extensions plugin.
|
void |
setupPluginRealm(PluginDescriptor pluginDescriptor,
MavenSession session,
java.lang.ClassLoader parent,
java.util.List<java.lang.String> imports,
org.eclipse.aether.graph.DependencyFilter filter)
Sets up the class realm for the specified plugin.
|
private java.util.List<org.eclipse.aether.artifact.Artifact> |
toAetherArtifacts(java.util.List<Artifact> pluginArtifacts) |
private java.util.List<Artifact> |
toMavenArtifacts(org.eclipse.aether.graph.DependencyNode root,
org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator nlg) |
private void |
validateParameters(MojoDescriptor mojoDescriptor,
org.codehaus.plexus.configuration.PlexusConfiguration configuration,
org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator) |
public static final java.lang.String KEY_EXTENSIONS_REALMS
PluginId => ExtensionRealmCache.CacheRecord map MavenProject context value key. The map is used to ensure the same class realm is used to load build extensions and load mojos for extensions=true plugins.
Note: This is part of internal implementation and may be changed or removed without notice@Requirement private org.codehaus.plexus.logging.Logger logger
@Requirement private org.codehaus.plexus.logging.LoggerManager loggerManager
@Requirement private org.codehaus.plexus.PlexusContainer container
@Requirement private ClassRealmManager classRealmManager
@Requirement private PluginDescriptorCache pluginDescriptorCache
@Requirement private PluginRealmCache pluginRealmCache
@Requirement private PluginDependenciesResolver pluginDependenciesResolver
@Requirement private RuntimeInformation runtimeInformation
@Requirement private ExtensionRealmCache extensionRealmCache
@Requirement private PluginVersionResolver pluginVersionResolver
@Requirement private PluginArtifactsCache pluginArtifactsCache
private ExtensionDescriptorBuilder extensionDescriptorBuilder
private PluginDescriptorBuilder builder
public PluginDescriptor getPluginDescriptor(Plugin plugin, java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
MavenPluginManager
getPluginDescriptor
in interface MavenPluginManager
plugin
- The plugin whose descriptor should be retrieved, must not be null
.repositories
- The plugin repositories to use for resolving the plugin's main artifact, must not be null
.session
- The repository session to use for resolving the plugin's main artifact, must not be null
.null
.PluginResolutionException
PluginDescriptorParsingException
InvalidPluginDescriptorException
private PluginDescriptor extractPluginDescriptor(Artifact pluginArtifact, Plugin plugin) throws PluginDescriptorParsingException, InvalidPluginDescriptorException
private java.lang.String getPluginDescriptorLocation()
private PluginDescriptor parsePluginDescriptor(java.io.InputStream is, Plugin plugin, java.lang.String descriptorLocation) throws PluginDescriptorParsingException
PluginDescriptorParsingException
public MojoDescriptor getMojoDescriptor(Plugin plugin, java.lang.String goal, java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session) throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
MavenPluginManager
getMojoDescriptor
in interface MavenPluginManager
plugin
- The plugin whose mojo descriptor should be retrieved, must not be null
.goal
- The simple name of the mojo whose descriptor should be retrieved, must not be null
.repositories
- The plugin repositories to use for resolving the plugin's main artifact, must not be null
.session
- The repository session to use for resolving the plugin's main artifact, must not be null
.null
.MojoNotFoundException
PluginResolutionException
PluginDescriptorParsingException
InvalidPluginDescriptorException
public void checkRequiredMavenVersion(PluginDescriptor pluginDescriptor) throws PluginIncompatibleException
MavenPluginManager
checkRequiredMavenVersion
in interface MavenPluginManager
pluginDescriptor
- The descriptor of the plugin to check, must not be null
.PluginIncompatibleException
public void setupPluginRealm(PluginDescriptor pluginDescriptor, MavenSession session, java.lang.ClassLoader parent, java.util.List<java.lang.String> imports, org.eclipse.aether.graph.DependencyFilter filter) throws PluginResolutionException, PluginContainerException
MavenPluginManager
setupPluginRealm
in interface MavenPluginManager
pluginDescriptor
- The plugin descriptor in which to save the class realm and the plugin artifacts, must not
be null
.session
- The build session from which to pick the current project and repository settings, must not be
null
.parent
- The parent class realm for the plugin, may be null
to use the Maven core realm.imports
- The packages/types to import from the parent realm, may be null
.filter
- The filter used to exclude certain plugin dependencies, may be null
.PluginResolutionException
PluginContainerException
private void createPluginRealm(PluginDescriptor pluginDescriptor, MavenSession session, java.lang.ClassLoader parent, java.util.Map<java.lang.String,java.lang.ClassLoader> foreignImports, org.eclipse.aether.graph.DependencyFilter filter) throws PluginResolutionException, PluginContainerException
private void discoverPluginComponents(org.codehaus.plexus.classworlds.realm.ClassRealm pluginRealm, Plugin plugin, PluginDescriptor pluginDescriptor) throws PluginContainerException
PluginContainerException
private java.util.List<org.eclipse.aether.artifact.Artifact> toAetherArtifacts(java.util.List<Artifact> pluginArtifacts)
private java.util.List<Artifact> toMavenArtifacts(org.eclipse.aether.graph.DependencyNode root, org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator nlg)
private java.util.Map<java.lang.String,java.lang.ClassLoader> calcImports(MavenProject project, java.lang.ClassLoader parent, java.util.List<java.lang.String> imports)
public <T> T getConfiguredMojo(java.lang.Class<T> mojoInterface, MavenSession session, MojoExecution mojoExecution) throws PluginConfigurationException, PluginContainerException
MavenPluginManager
MavenPluginManager.releaseMojo(Object, MojoExecution)
when the mojo is no longer needed to free any resources allocated for
it.getConfiguredMojo
in interface MavenPluginManager
mojoInterface
- The component role of the mojo, must not be null
.session
- The build session in whose context the mojo will be used, must not be null
.mojoExecution
- The mojo execution to retrieve the mojo for, must not be null
.null
.PluginConfigurationException
PluginContainerException
private void populatePluginFields(java.lang.Object mojo, MojoDescriptor mojoDescriptor, org.codehaus.plexus.classworlds.realm.ClassRealm pluginRealm, org.codehaus.plexus.configuration.PlexusConfiguration configuration, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator) throws PluginConfigurationException
PluginConfigurationException
private void validateParameters(MojoDescriptor mojoDescriptor, org.codehaus.plexus.configuration.PlexusConfiguration configuration, org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator expressionEvaluator) throws org.codehaus.plexus.component.configurator.ComponentConfigurationException, PluginParameterException
org.codehaus.plexus.component.configurator.ComponentConfigurationException
PluginParameterException
public void releaseMojo(java.lang.Object mojo, MojoExecution mojoExecution)
MavenPluginManager
releaseMojo
in interface MavenPluginManager
mojo
- The mojo to release, may be null
.mojoExecution
- The mojo execution the mojo was originally retrieved for, must not be null
.public ExtensionRealmCache.CacheRecord setupExtensionsRealm(MavenProject project, Plugin plugin, org.eclipse.aether.RepositorySystemSession session) throws PluginManagerException
MavenPluginManager
setupExtensionsRealm
in interface MavenPluginManager
PluginManagerException
private java.util.List<Artifact> resolveExtensionArtifacts(Plugin extensionPlugin, java.util.List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session) throws PluginResolutionException
PluginResolutionException