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 ...

Get Maven: The Definitive Guide 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.