Java Reference
In-Depth Information
phases are already defined for us in the order in which we listed them. And Maven
invokes these phases in a strict order: they get executed sequentially in the order
listed to complete the lifecycle. This means that if you invoke any of them, for exam-
ple, if you type
mvn compile
on the command line in your project's home directory, Maven will first validate the
project and then try to compile the sources of your project.
One last thing—it's useful to think of all these phases as extension points. At any
moment you can attach additional Maven plug-ins to the phases and orchestrate the
order and the way these plug-ins are executed.
10.1.4
Plug-in-based architecture
The last feature of Maven that we'll mention is its plug-in-based architecture. At the
beginning of this chapter, we said that Ant is a source-building framework and Maven
is a source-building environment. More specifically, Maven is a plug-in, execution,
source-building environment. The core of the project is small, but the architecture of
the project allows multiple plug-ins to be attached to the core, and so Maven builds an
environment where different plug-ins can get executed.
Each of the phases in a given lifecycle has a number of plug-ins attached to that
phase, and Maven invokes them when passing through the given phase in the order in
which the plug-ins are declared. Here are some of the core Maven plug-ins:
Clean plug-in —Cleans up after the build
Compiler plug-in —Compiles Java sources
Deploy plug-in —Deploys the built artifact to the remote repository
Install plug-in —Installs the built artifact into the local repository
Resources plug-in —Copies the resources to the output directory for inclusion in
the JAR
Site plug-in —Generates a site for the current project
Surefire plug-in —Runs the JU nit tests in an isolated classloader
Verifier plug-in —Useful for integration tests; verifies the existence of certain
conditions
Apart from these core Maven plug-ins, there are also dozens of other Maven plug-ins
for every kind of situation you may need— WAR plug-in, Javadoc plug-in, AntRun plug-
in—you name it.
Plug-ins are declared in the plugins section of your build configuration file,
for instance:
<build>
<plugins>
<plugin>
<groupId>org.apache.cactus</groupId>
 
 
 
Search WWH ::




Custom Search