List of usage examples for org.apache.maven.lifecycle LifecycleMappingDelegate calculateLifecycleMappings
Map<String, List<MojoExecution>> calculateLifecycleMappings(MavenSession session, MavenProject project,
Lifecycle lifecycle, String lifecyclePhase) throws PluginNotFoundException, PluginResolutionException,
PluginDescriptorParsingException, MojoNotFoundException, InvalidPluginDescriptorException;
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); }//w ww . j a v a 2 s . c o m 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); } }