Search in sources :

Example 1 with PluginManagerException

use of org.apache.maven.plugin.PluginManagerException in project maven-plugins by apache.

the class PdfMojo method getMavenReport.

/**
     * @param mojoDescriptor not null
     * @return the MavenReport instance for the given mojoDescriptor.
     * @throws MojoExecutionException if any
     * @since 1.1
     */
private MavenReport getMavenReport(MojoDescriptor mojoDescriptor) throws MojoExecutionException {
    ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        Thread.currentThread().setContextClassLoader(mojoDescriptor.getPluginDescriptor().getClassRealm().getClassLoader());
        MojoExecution mojoExecution = new MojoExecution(mojoDescriptor);
        return pluginManager.getReport(project, mojoExecution, session);
    } catch (ArtifactNotFoundException e) {
        throw new MojoExecutionException("ArtifactNotFoundException: " + e.getMessage(), e);
    } catch (ArtifactResolutionException e) {
        throw new MojoExecutionException("ArtifactResolutionException: " + e.getMessage(), e);
    } catch (PluginConfigurationException e) {
        throw new MojoExecutionException("PluginConfigurationException: " + e.getMessage(), e);
    } catch (PluginManagerException e) {
        throw new MojoExecutionException("PluginManagerException: " + e.getMessage(), e);
    } finally {
        Thread.currentThread().setContextClassLoader(oldClassLoader);
    }
}
Also used : ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoExecution(org.apache.maven.plugin.MojoExecution) PluginConfigurationException(org.apache.maven.plugin.PluginConfigurationException) ArtifactNotFoundException(org.apache.maven.artifact.resolver.ArtifactNotFoundException) PluginManagerException(org.apache.maven.plugin.PluginManagerException)

Aggregations

ArtifactNotFoundException (org.apache.maven.artifact.resolver.ArtifactNotFoundException)1 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)1 MojoExecution (org.apache.maven.plugin.MojoExecution)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 PluginConfigurationException (org.apache.maven.plugin.PluginConfigurationException)1 PluginManagerException (org.apache.maven.plugin.PluginManagerException)1