List of usage examples for org.apache.maven.lifecycle Lifecycle getPhases
public List<String> getPhases()
From source file:io.fabric8.maven.core.util.GoalFinder.java
License:Apache License
private boolean checkGoalInPhase(MavenProject project, MavenSession session, String goal, String phase) throws MojoExecutionException { Lifecycle lifecycle = defaultLifeCycles.get(phase); if (lifecycle == null) { throw new MojoExecutionException("Cannot find lifecycle phase " + phase); }//from www .j a v a2 s . c om LifecycleMappingDelegate delegate = findDelegate(lifecycle); try { Map<String, List<MojoExecution>> executionsMap = delegate.calculateLifecycleMappings(session, project, lifecycle, phase); boolean foundPhase = false; boolean foundGoal = false; for (String p : lifecycle.getPhases()) { List<MojoExecution> executions = executionsMap.get(p); if (executions != null) { for (MojoExecution execution : executions) { MojoDescriptor desc = execution.getMojoDescriptor(); if (desc != null && desc.getFullGoalName().equals(goal)) { foundGoal = true; break; } } } if (phase.equals(p)) { foundPhase = true; break; } } return foundPhase && foundGoal; } catch (Exception e) { throw new MojoExecutionException("Interna: Cannot extract executions", e); } }
From source file:org.codehaus.mojo.versions.DisplayPluginUpdatesMojo.java
License:Apache License
/** * Gets the phase to lifecycle map./*from ww w .j a va2 s . c o 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; }