O'Reilly logo

Harnessing Hibernate by James Elliott, Ryan Fowler, Timothy M. O'Brien

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Maven Build Lifecycle

We’ve talked about the lifecycle in the previous sections of this chapter, so by now you’ve gathered that there is a compile phase, a test phase, a package phase, and an install phase. In Example 12-3 we attached the hbm2ddl goal to the process-classes phase, and we mentioned that this phase follows the compile phase. If this all seems like Voodoo, don’t worry—we’ll briefly explain the phases in the lifecycle and the order in which they’re executed. When you run Maven from the command line you have the choice of specifying the name of a phase or of executing a plug-in goal explicitly. When you specify a phase, Maven will execute all of the phases in the Maven lifecycle up to and including the specified phase. As Maven progresses through the Build Lifecycle it triggers plug-in goals which have been attached to the current phase. If, on the other hand, you request a plug-in goal explicitly, Maven will only execute that single plug-in goal.

Here’s a list of all the Maven phases, in the order in which they occur. The phases that are important to our examples are explained in some detail, whereas other phases have been combined to save some space:

validate

Validates the POM.

generate-sources

Generates any source code. The Hibernate3 plug-in has an hbm2java goal which we could use to generate Java from XML-based mappings (as we did in previous chapters). If we wanted to do that, it would make sense for us to attach hbm2java to this phase.

process-sources, generate-resources ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required