List of usage examples for org.apache.maven.lifecycle.mapping LifecycleMapping ROLE
String ROLE
To view the source code for org.apache.maven.lifecycle.mapping LifecycleMapping ROLE.
Click Source Link
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Find mappings for lifecycle.//from w w w . j a v a2s . 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 optional mojos for lifecycle./* ww w . j a v a 2s . com*/ * * @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; }