You are previewing Maven: The Definitive Guide.

Maven: The Definitive Guide

Cover of Maven: The Definitive Guide by Sonatype Company Published by O'Reilly Media, Inc.
O'Reilly logo

Package-Specific Lifecycles

The specific goals bound to each phase default to a set of goals specific to a project’s packaging. A project with jar packaging has a different set of default goals from a project with a packaging of war. The packaging element affects the steps required to build a project. For an example of how the packaging affects the build, consider two projects: one with pom packaging and the other with jar packaging. The project with pom packaging will run the site:attach-descriptor goal during the package phase, and the project with jar packaging will run the jar:jar goal instead.

The following sections describe the lifecycle for all built-in packaging types in Maven. Use these sections to find out which default goals are mapped to default lifecycle phases.

JAR

JAR is the default packaging type—the most common and thus the most commonly encountered lifecycle configuration. The default goals for the JAR lifecycle are shown in Table 10-2.

Table 10-2. Default goals for JAR packaging

Lifecycle phaseGoal
process-resourcesresources:resources
compilecompiler:compile
process-test-resourcesresources:testResources
test-compilecompiler:testCompile
testsurefire:test
packagejar:jar
installinstall:install
deploydeploy:deploy

POM

POM is the simplest packaging type. The artifact that it generates is itself only, rather than a JAR, SAR, or EAR. There is no code to test or compile, and there are no resources to process. The default goals for projects with POM packaging are shown in Table 10-3 ...

The best content for your career. Discover unlimited learning on demand for around $1/day.