Chapter 12. Maven in More Depth
If you download our code examples from the O’Reilly website, you’ll notice that every chapter’s example directory contains a mysterious pom.xml file which we haven’t mentioned yet. This pom.xml is the configuration for a build tool called Apache Maven, a widely used alternative to Apache Ant. A full introduction to Maven is outside the scope of this book, but we did think that it was important enough to include some instructions for installing and using Maven with Hibernate. This chapter is an attempt at the shortest introduction to Maven on record, focusing on using Maven and the Hibernate3 plug-in. Along the way, we’ll introduce some of the core concepts in Maven.
What Is Maven?
Maven is a declarative build tool. Instead of defining a set of procedural steps to build a project, you describe your project using a Project Object Model (POM) in a pom.xml file. All the heavy lifting is done by Maven plug-ins, which are a set of goals that know how to read your POM and accomplish a task. For example, there are default Maven plug-ins that compile code, create JAR files, assemble WAR files, create web sites, sign JAR files, run code metrics, execute unit tests, read Hibernate mapping files, and more. All you need to do to use Maven is tell it where the source code is and what your dependencies are—Maven is smart enough to figure out what to do next. The alternative to Maven is to define an explicit build procedure using a tool like Apache Ant. Maven provides ...
Get Harnessing Hibernate now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.