use of org.apache.maven.lifecycle.LifecycleMappingDelegate in project fabric8-maven-plugin by fabric8io.
the class GoalFinder method findDelegate.
// Find a delegate
private LifecycleMappingDelegate findDelegate(Lifecycle lifecycle) {
LifecycleMappingDelegate delegate;
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;
}
use of org.apache.maven.lifecycle.LifecycleMappingDelegate in project fabric8-maven-plugin by fabric8io.
the class GoalFinder method checkGoalInPhase.
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);
}
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);
}
}
Aggregations