List of usage examples for org.apache.maven.lifecycle Lifecycle getId
public String getId()
From source file:io.fabric8.maven.core.util.GoalFinder.java
License:Apache License
private LifecycleMappingDelegate findDelegate(Lifecycle lifecycle) { LifecycleMappingDelegate delegate;//from ww w .ja va 2 s. c o m String lifecycleId = lifecycle.getId(); if (Arrays.binarySearch(DefaultLifecycles.STANDARD_LIFECYCLES, lifecycleId) >= 0) { delegate = standardDelegate; } else { delegate = delegates.get(lifecycleId); if (delegate == null) { delegate = standardDelegate; } } return delegate; }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Find mappings for lifecycle./*from w w w.ja va 2s.c om*/ * * @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.//from w ww . j a va 2s .c om * * @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; }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Gets the phase to lifecycle map.// w ww . j av a 2s .co m * * @param lifecycles The list of lifecycles. * @return the phase to lifecycle map. * @throws LifecycleExecutionException the lifecycle execution exception. */ public Map getPhaseToLifecycleMap(List lifecycles) throws LifecycleExecutionException { Map phaseToLifecycleMap = new HashMap(); for (Iterator i = lifecycles.iterator(); i.hasNext();) { Lifecycle lifecycle = (Lifecycle) i.next(); for (Iterator p = lifecycle.getPhases().iterator(); p.hasNext();) { String phase = (String) p.next(); if (phaseToLifecycleMap.containsKey(phase)) { Lifecycle prevLifecycle = (Lifecycle) phaseToLifecycleMap.get(phase); throw new LifecycleExecutionException( "Phase '" + phase + "' is defined in more than one lifecycle: '" + lifecycle.getId() + "' and '" + prevLifecycle.getId() + "'"); } else { phaseToLifecycleMap.put(phase, lifecycle); } } } return phaseToLifecycleMap; }