I\'m just learning Maven, and so this might be obvious, but I can\'t find an easy way to list the goals associated for each maven lifecycle phase for a given project.
If not with Maven but using m2e you can do it using the code block that you can use in a Eclipse plugin:
final IMavenProjectRegistry projectRegistry = MavenPlugin.getMavenProjectRegistry();
final IMavenProjectFacade facade = projectRegistry.getProject(project);
projectRegistry.execute(facade, new ICallable() {
public Void call(IMavenExecutionContext context, IProgressMonitor monitor) throws CoreException {
MavenProject mavenProject = facade.getMavenProject(monitor);
List mojoExecutions = ((MavenProjectFacade) facade).getMojoExecutions(monitor);
LifecycleMappingResult mappingResult = LifecycleMappingFactory.calculateLifecycleMapping(
mavenProject, mojoExecutions, facade.getResolverConfiguration().getLifecycleMappingId(),
monitor);
Map> mojoExecutionMapping = mappingResult
.getMojoExecutionMapping();
Map> phases = new LinkedHashMap>();
for (MojoExecutionKey execution : mojoExecutionMapping.keySet()) {
List executions = phases.get(execution.getLifecyclePhase());
if (executions == null) {
executions = new ArrayList();
phases.put(execution.getLifecyclePhase(), executions);
}
executions.add(execution);
}
Look at full source.
Already implemented in:
http://marketplace.eclipse.org/content/phases-and-goals
It makes use of m2e's ability to compute the association of goals with phases. I am also trying to solve it at maven level.