Maven: The Complete Reference - 4.2. 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 packaging The following sections describe the lifecycle for all built-in packaging types in Maven. Use these sections to find out what default goals are mapped to default lifecycle phases. 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 4.2, “Default Goals for JAR Packaging”. Table 4.2. Default Goals for JAR Packaging
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 the process. The default goals for projects with POM packaging are shown in Table 4.3, “Default Goals for POM Packaging”. Table 4.3. Default Goals for POM Packaging
This packaging type is similar to JAR packaging type with three
additions: Table 4.4. Default Goals for Plugin Packaging
EJBs, or Enterprise Java Beans, are a common data access mechanism for model-driven development in Enterprise Java. Maven provides support for EJB 2 and 3. Though you must configure the EJB plugin to specifically package for EJB3, else the plugin defaults to 2.1 and looks for the presence of certain EJB configuration files. The default goals for projects with EJB packaging are shown in Table 4.5, “Default Goals for EJB Packaging”. Table 4.5. Default Goals for EJB Packaging
The WAR packaging type is similar to the JAR and EJB types. The
exception being the Table 4.6. Default Goals for WAR Packaging
EARs are probably the simplest Java EE constructs, consisting
primarily of the deployment descriptor application.xml file, some
resources and some modules. The EAR plugin has a goal named
Table 4.7. Default Goals for EAR Packaging
This is not an exhaustive list of every packaging type available for Maven. There are a number of packaging formats available through external projects and plugins: the NAR (native archive) packaging type, the SWF and SWC packaging types for projects that produce Adobe Flash and Flex content, and many others. You can also define a custom packaging type and customize the default lifecycle goals to suit your own project packaging requirements. To use one of these custom packaging types, you need two things: a plugin which defines the lifecycle for a custom packaging type and a repository which contains this plugin. Some custom packaging types are defined in plugins available from the central Maven repository. Here is an example of a project which references the Israfil Flex plugin and uses a custom packaging type of SWF to produce output from Adobe Flex source. Custom Packaging Type for Adobe Flex (SWF). <project> ... <packaging>swf</packaging> ... <build> <plugins> <plugin> <groupId>net.israfil.mojo</groupId> <artifactId>maven-flex2-plugin</artifactId> <version>1.4-SNAPSHOT</version> <extensions>true</extensions> <configuration> <debug>true</debug> <flexHome>${flex.home}</flexHome> <useNetwork>true</useNetwork> <main>org/sonatype/mavenbook/Main.mxml</main> </configuration> </plugin> </plugins> </build> ... </project>
In Section 11.6, “Plugins and the Maven Lifecycle”, we show you how to create your own packaging type with a customized lifecycle. This example should give you an idea of what you’ll need to do to reference a custom packaging type. All you need to do is reference the plugin which supplies the custom packaging type. The Israfil Flex plugin is a third-party Maven plugin hosted at Google Code, for more information about this plugin and how to use Maven to compile Adobe Flex go to http://code.google.com/p/israfil-mojo. This plugin supplies the following lifecycle for the SWF packaging type: Table 4.8. Default Lifecycle for SWF Packaging
|