tags:

views:

683

answers:

2

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.

I saw that the Maven default life cycle phases and corresponding default goals are documented here. My understanding so far is that each pom.xml can bind additional goals to each lifecycle phase.

So, is there a mvn command to determine the goals that will be run for each lifecycle phase for a given project? If not, I guess I just have to look through the pom.xml for each new maven project to figure this out?

+3  A: 

One tool that helps is mvn help:effective-pom It will print the POM with all variables ant all parent POMs expanded. This helps to understand what Maven sees. From that, it's pretty simple to find all the additional goals (which usually aren't that many).

The bigger problem is the implicit goals (i.e. when a plugin hooks itself to some phases of the lifecycle automatically). There is no easy way to see these without actually running Maven. This should become better in Maven 3. Until then, run Maven with -X which will print a whole lot of debug output plus the current phase and which plugins are executed.

Aaron Digulla
Thanks, Aaron, this was helpful!
Dave Paroulek
How is this getting better in Maven 3? Is it in the current alpha-6?
Lars Corneliussen
Jason told me that the new Maven 3 will build a model of the whole build before actually starting it. That means that you can examine (and print) the hooks without running the commands.
Aaron Digulla
+2  A: 

mvn help:describe -Dcmd=compile (or any other valid phase)

Akira