Skip to Main Content
Maven: The Definitive Guide
book

Maven: The Definitive Guide

by Sonatype Company
September 2008
Intermediate to advanced content levelIntermediate to advanced
470 pages
14h 22m
English
O'Reilly Media, Inc.
Content preview from Maven: The Definitive Guide

Chapter 10. The Build Lifecycle

Introduction

Maven models projects as nouns that are described by a POM. The POM captures the identity of a project: What does a project contain? What type of packaging does a project need? Does the project have a parent? What are the dependencies? We’ve explored the idea of describing a project in the previous chapters, but we haven’t introduced the mechanism that allows Maven to act upon these objects. In Maven, the “verbs” are goals packaged in Maven plugins that are tied to phases in a build lifecycle. A Maven lifecycle consists of a sequence of named phases: prepare-resources, compile, package, and install, among others. There is a phase that captures compilation and a phase that captures packaging. There are pre- and postphases that can be used to register goals that must run prior to compilation, or tasks that must be run after a particular phase. When you tell Maven to build a project, you are telling Maven to step through a defined sequence of phases and to execute any goals that may have been registered with each phase.

A build lifecycle is an organized sequence of phases that exist to give order to a set of goals. Those goals are chosen and bound by the packaging type of the project being acted upon. There are three standard lifecycles in Maven: clean, default (sometimes called build), and site. In this chapter, you will learn how Maven ties goals to lifecycle phases and how the lifecycle can be customized. You will also learn about the default ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Apache Maven Cookbook

Apache Maven Cookbook

Raghuram Bharathan
Mastering Apache Maven 3

Mastering Apache Maven 3

Prabath Siriwardena
Learning Apache Maven

Learning Apache Maven

Kevin Bowersox

Publisher Resources

ISBN: 9780596517335Supplemental ContentErrata Page