views:

799

answers:

2

I have maven installed and I'm trying to go through the hibernate tutorial. But how exactly am I suppose to use this file: http://docs.jboss.org/hibernate/stable/core/reference/en/html/tutorial.html#tutorial-firstapp-setup

What does maven need to do with it? What exactly does that file do?

+1  A: 

That file is called pom.xml and provides a definition of your project to maven so it would be able to build it. Save it in the root folder of your project and run mvn install from the same place to build the project. If you need more info you should read some maven documentation and tutorials.

Gregory Mostizky
+2  A: 

Maven uses a Project Object Model to describe a project. This includes definitions of the dependencies and executions to use for a project, the reports to run when building, and a host of other features. In Maven 2 that model is defined in the pom.xml (in Maven 1 the file was called project.xml).

Maven expects to find the pom.xml in the root directory of the project (though this can be overridden). When you run a Maven goal, the POM is parsed from pom.xml, Maven determines what dependencies and plugins are needed, downloading them from the remote repositories, then runs the plugins that are configured for the project.

For a jar project, running mvn install will by default perform a series of operations based on the default lifecycle bindings. You can define additional operations by adding plugin definitions to the pom and binding them to the relevant phase of the lifecycle.

The Maven book is a good guide to Maven. The Maven by Example section will walk you through the various parts of Maven configuration. If you are familiar with Ant, have a look at the Comparing Maven with Ant section to understand the differences.

Rich Seller
excellent description
Schildmeijer