Interface MavenPluginManager

All Known Implementing Classes:
DefaultMavenPluginManager

public interface MavenPluginManager
Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such that the plugins/mojos can be used in arbitrary contexts. In particular, the mojos can be used for ordinary build plugins as well as special purpose plugins like reports.
Since:
3.0
Author:
Benjamin Bentmann
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    checkRequiredMavenVersion(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor)
    Verifies the specified plugin is compatible with the current Maven runtime.
    <T> T
    getConfiguredMojo(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.
    org.apache.maven.plugin.descriptor.MojoDescriptor
    getMojoDescriptor(org.apache.maven.model.Plugin plugin, String goal, 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.
    org.apache.maven.plugin.descriptor.PluginDescriptor
    getPluginDescriptor(org.apache.maven.model.Plugin plugin, List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session)
    Retrieves the descriptor for the specified plugin from its main artifact.
    void
    releaseMojo(Object mojo, MojoExecution mojoExecution)
    Releases the specified mojo back to the container.
    setupExtensionsRealm(MavenProject project, org.apache.maven.model.Plugin plugin, org.eclipse.aether.RepositorySystemSession session)
    Sets up class realm for the specified build extensions plugin.
    void
    setupPluginRealm(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, List<String> imports, org.eclipse.aether.graph.DependencyFilter filter)
    Sets up the class realm for the specified plugin.
  • Method Details

    • getPluginDescriptor

      org.apache.maven.plugin.descriptor.PluginDescriptor getPluginDescriptor(org.apache.maven.model.Plugin plugin, List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session) throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
      Retrieves the descriptor for the specified plugin from its main artifact.
      Parameters:
      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.
      Returns:
      The plugin descriptor, never null.
      Throws:
      PluginResolutionException
      PluginDescriptorParsingException
      InvalidPluginDescriptorException
    • getMojoDescriptor

      org.apache.maven.plugin.descriptor.MojoDescriptor getMojoDescriptor(org.apache.maven.model.Plugin plugin, String goal, List<org.eclipse.aether.repository.RemoteRepository> repositories, org.eclipse.aether.RepositorySystemSession session) throws org.apache.maven.plugin.MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
      Retrieves the descriptor for the specified plugin goal from the plugin's main artifact.
      Parameters:
      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.
      Returns:
      The mojo descriptor, never null.
      Throws:
      org.apache.maven.plugin.MojoNotFoundException
      PluginResolutionException
      PluginDescriptorParsingException
      InvalidPluginDescriptorException
    • checkRequiredMavenVersion

      void checkRequiredMavenVersion(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor) throws PluginIncompatibleException
      Verifies the specified plugin is compatible with the current Maven runtime.
      Parameters:
      pluginDescriptor - The descriptor of the plugin to check, must not be null.
      Throws:
      PluginIncompatibleException
    • setupPluginRealm

      void setupPluginRealm(org.apache.maven.plugin.descriptor.PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent, List<String> imports, org.eclipse.aether.graph.DependencyFilter filter) throws PluginResolutionException, PluginContainerException
      Sets up the class realm for the specified plugin. Both the class realm and the plugin artifacts that constitute it will be stored in the plugin descriptor.
      Parameters:
      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.
      Throws:
      PluginResolutionException
      PluginContainerException
    • setupExtensionsRealm

      ExtensionRealmCache.CacheRecord setupExtensionsRealm(MavenProject project, org.apache.maven.model.Plugin plugin, org.eclipse.aether.RepositorySystemSession session) throws PluginManagerException
      Sets up class realm for the specified build extensions plugin.
      Throws:
      PluginManagerException
      Since:
      3.3.0
    • getConfiguredMojo

      <T> T getConfiguredMojo(Class<T> mojoInterface, MavenSession session, MojoExecution mojoExecution) throws PluginConfigurationException, PluginContainerException
      Looks up the mojo for the specified mojo execution and populates its parameters from the configuration given by the mojo execution. The mojo/plugin descriptor associated with the mojo execution provides the class realm to lookup the mojo from. Warning: The returned mojo instance must be released via releaseMojo(Object, MojoExecution) when the mojo is no longer needed to free any resources allocated for it.
      Parameters:
      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.
      Returns:
      The ready-to-execute mojo, never null.
      Throws:
      PluginConfigurationException
      PluginContainerException
    • releaseMojo

      void releaseMojo(Object mojo, MojoExecution mojoExecution)
      Releases the specified mojo back to the container.
      Parameters:
      mojo - The mojo to release, may be null.
      mojoExecution - The mojo execution the mojo was originally retrieved for, must not be null.