Example usage for org.apache.maven.lifecycle Lifecycle getDefaultPhases

List of usage examples for org.apache.maven.lifecycle Lifecycle getDefaultPhases

Introduction

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

Prototype

@Deprecated
    public Map<String, String> getDefaultPhases() 

Source Link

Usage

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

License:Apache License

/**
 * Find mappings for lifecycle./*from www. j a v  a2 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;
}