Introduction

Maven is a tool for building and managing Java applications. Maven uses a standard structure so that you don't have to spend your time manually describing your build process. This allows you to concentrate on writing code instead of managing your build scripts.

Although it's not required, you generally start a Maven project by using an Archetype. Archetypes are like templates for a Maven project. They supply a starting point for common project layouts and dependencies so you don't have to start for scratch.

The basis of any Maven project is the Project Object Model (POM) which is represented by the file pom.xml in the root of your project. You define Dependencies which specify other Maven projects and and components you may need when compiling, testing, running or delivering your app. You can incorporate Plugins which provide Goals that accomplish tasks for building and reporting about your project.

Repositories are structured collections of Artifacts - the Archetypes, Plugins and Dependencies you need. They can be Maven's own central repository, a third-party repository, one your company sets up or your local filesystem.

Life Cycles contain Phases which define ordered steps used to clean, build and document your project. Packaging defines how your artifact will be delivered. It could be a JAR, WAR, EAR or several other types. The packaging you choose influences what Plugin Goals are associated with each Lifecycle Phase.

The output of your Maven Project is an Artifact which could be an application, a library, your own Plugin or even a custom Archetype to generate other projects.

A diagram of these various concepts and their relationships can be see in Figure 1 on the next page.

Figure 1: Maven Concepts

Who Is This Book For?

This book is for Java developers who need to use Maven or are curious how it works. It assumes you've already made the decision to use Maven or are working with Maven-based projects. This books is not trying to convince you to use Maven, only telling you how.

If you've used Apache Ant to build your projects, that's great. I've used it too and it works pretty well. Throughout writing this book I've gained an appreciation for Maven and intend to use it on future projects, but convincing your IT department to switch to maven falls outside the scope of the book. Hopefully, though, the information provided will armor you to convince others about the benefits of Maven and how easy it makes things once you learn its conventions and commands.

How to Read This Book

TK

What Version of Maven to Use

Maven 3.0.3

How Maven Works

TK

Project Object Model

TK

The Lifecycle Model

TK

Maven Repositories

TK

Dependency Management

TK

Maven Plugins

TK