Example usage for org.apache.maven.lifecycle.mapping LifecycleMapping getOptionalMojos

List of usage examples for org.apache.maven.lifecycle.mapping LifecycleMapping getOptionalMojos

Introduction

In this page you can find the example usage for org.apache.maven.lifecycle.mapping LifecycleMapping getOptionalMojos.

Prototype

@Deprecated
    List<String> getOptionalMojos(String lifecycle);

Source Link

Usage

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

License:Apache License

/**
 * Find optional mojos for lifecycle./*ww  w . ja  v  a2s.  co  m*/
 *
 * @param project   the project
 * @param lifecycle the lifecycle
 * @return the list
 * @throws LifecycleExecutionException the lifecycle execution exception
 * @throws PluginNotFoundException     the plugin not found exception
 */
private List<String> findOptionalMojosForLifecycle(MavenProject project, Lifecycle lifecycle)
        throws LifecycleExecutionException, PluginNotFoundException {
    String packaging = project.getPackaging();
    List<String> optionalMojos = null;

    LifecycleMapping m = (LifecycleMapping) findExtension(project, LifecycleMapping.ROLE, packaging,
            session.getSettings(), session.getLocalRepository());

    if (m != null) {
        optionalMojos = m.getOptionalMojos(lifecycle.getId());
    }

    if (optionalMojos == null) {
        try {
            m = (LifecycleMapping) session.lookup(LifecycleMapping.ROLE, packaging);
            optionalMojos = m.getOptionalMojos(lifecycle.getId());
        } catch (ComponentLookupException e) {
            getLog().debug("Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: "
                    + lifecycle.getId() + ". Error: " + e.getMessage(), e);
        }
    }

    if (optionalMojos == null) {
        optionalMojos = Collections.emptyList();
    }

    return optionalMojos;
}