Example usage for org.apache.maven.lifecycle LifecycleExecutionException LifecycleExecutionException

List of usage examples for org.apache.maven.lifecycle LifecycleExecutionException LifecycleExecutionException

Introduction

In this page you can find the example usage for org.apache.maven.lifecycle LifecycleExecutionException LifecycleExecutionException.

Prototype

public LifecycleExecutionException(String message, MavenProject project) 

Source Link

Usage

From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java

License:Apache License

/**
 * Find mappings for lifecycle./*w w w  . ja  va  2 s .  c o m*/
 *
 * @param project   the project
 * @param lifecycle the lifecycle
 * @return the map
 * @throws LifecycleExecutionException the lifecycle execution exception
 * @throws PluginNotFoundException     the plugin not found exception
 */
private Map findMappingsForLifecycle(MavenProject project, Lifecycle lifecycle)
        throws LifecycleExecutionException, PluginNotFoundException {
    String packaging = project.getPackaging();
    Map mappings = null;

    LifecycleMapping m = (LifecycleMapping) findExtension(project, LifecycleMapping.ROLE, packaging,
            session.getSettings(), session.getLocalRepository());
    if (m != null) {
        mappings = m.getPhases(lifecycle.getId());
    }

    Map defaultMappings = lifecycle.getDefaultPhases();

    if (mappings == null) {
        try {
            m = (LifecycleMapping) session.lookup(LifecycleMapping.ROLE, packaging);
            mappings = m.getPhases(lifecycle.getId());
        } catch (ComponentLookupException e) {
            if (defaultMappings == null) {
                throw new LifecycleExecutionException(
                        "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e);
            }
        }
    }

    if (mappings == null) {
        if (defaultMappings == null) {
            throw new LifecycleExecutionException("Cannot find lifecycle mapping for packaging: \'" + packaging
                    + "\', and there is no default");
        } else {
            mappings = defaultMappings;
        }
    }

    return mappings;
}

From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java

License:Apache License

/**
 * Find extension.//from  www. ja  v  a2 s.c o  m
 *
 * @param project         the project
 * @param role            the role
 * @param roleHint        the role hint
 * @param settings        the settings
 * @param localRepository the local repository
 * @return the object
 * @throws LifecycleExecutionException the lifecycle execution exception
 * @throws PluginNotFoundException     the plugin not found exception
 */
private Object findExtension(MavenProject project, String role, String roleHint, Settings settings,
        ArtifactRepository localRepository) throws LifecycleExecutionException, PluginNotFoundException {
    Object pluginComponent = null;

    for (Iterator i = project.getBuildPlugins().iterator(); i.hasNext() && pluginComponent == null;) {
        Plugin plugin = (Plugin) i.next();

        if (plugin.isExtensions()) {
            loadPluginDescriptor(plugin, project, session);

            // TODO: if moved to the plugin manager we
            // already have the descriptor from above
            // and so do can lookup the container
            // directly
            try {
                pluginComponent = pluginManager.getPluginComponent(plugin, role, roleHint);
            } catch (ComponentLookupException e) {
                getLog().debug("Unable to find the lifecycle component in the extension", e);
            } catch (PluginManagerException e) {
                throw new LifecycleExecutionException(
                        "Error getting extensions from the plugin '" + plugin.getKey() + "': " + e.getMessage(),
                        e);
            }
        }
    }
    return pluginComponent;
}

From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java

License:Apache License

/**
 * Verify plugin./*from   w ww .  j  av  a2s. c  o m*/
 *
 * @param plugin  the plugin
 * @param project the project
 * @param session the session
 * @return the plugin descriptor
 * @throws LifecycleExecutionException the lifecycle execution exception
 * @throws PluginNotFoundException     the plugin not found exception
 */
private PluginDescriptor loadPluginDescriptor(Plugin plugin, MavenProject project, MavenSession session)
        throws LifecycleExecutionException, PluginNotFoundException {
    PluginDescriptor pluginDescriptor;
    try {
        pluginDescriptor = pluginManager.loadPluginDescriptor(plugin, project, session);
    } catch (PluginManagerException e) {
        throw new LifecycleExecutionException("Internal error in the plugin manager getting plugin '"
                + plugin.getKey() + "': " + e.getMessage(), e);
    } catch (PluginVersionResolutionException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    } catch (InvalidVersionSpecificationException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    } catch (InvalidPluginException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    } catch (ArtifactNotFoundException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    } catch (ArtifactResolutionException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    } catch (PluginVersionNotFoundException e) {
        throw new LifecycleExecutionException(e.getMessage(), e);
    }
    return pluginDescriptor;
}