mirror of https://github.com/apache/maven.git
o little additions
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163353 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
89c4612bf8
commit
dd522ff10c
|
@ -40,11 +40,21 @@ Maven Lifecycle Phases
|
||||||
|
|
||||||
* deploy
|
* deploy
|
||||||
|
|
||||||
o phases are used as join points (before/around/after)
|
Mojos only know what they need as input and what phase they contribute to perform their task.
|
||||||
o mojos specify what phase they are contributing to
|
They don't know anything about Maven specifically because Maven controls how they are executed in the lifecycle
|
||||||
o use goal names to protect from changes in the goal specifics themselves
|
using the lifecycle configuration which looks like the following:
|
||||||
o the phases are really placeholders for various goals to be executed and it would be the phases that the user
|
|
||||||
could specify on the CLI so something like
|
+-----+
|
||||||
|
|
||||||
|
%{snippet|id=lifecycle|url=http://cvs.apache.org/viewcvs.cgi/*checkout*/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml}
|
||||||
|
|
||||||
|
+-----+
|
||||||
|
|
||||||
|
You can see that we use the mojo id to indicate what mojo we want to execute at a particular place in the lifecycle
|
||||||
|
to protected against any package refactoring and generally protects against any changes that might occur with
|
||||||
|
naming.
|
||||||
|
|
||||||
|
An example of something commonly done is Maven is to compile the sources of your project:
|
||||||
|
|
||||||
+-----+
|
+-----+
|
||||||
|
|
||||||
|
@ -54,18 +64,20 @@ m2 compile
|
||||||
|
|
||||||
This would invoke the lifecycle up to, and including, the compile phase.
|
This would invoke the lifecycle up to, and including, the compile phase.
|
||||||
|
|
||||||
This may seem a bit lengthly but I think it covers anything that could possibly be done and there is enough flexibility
|
What about mojos that fall outside of this standard lifecycle? Things like <<<clean:clean>>>, <<<archetype:create>>>,
|
||||||
within the lifecycle to accommodate users i.e. we don't need to have a boundless set of lifecycle phases. What people
|
and <<<idea:idea>>>? These mojos can be executed by invoking Maven as such.
|
||||||
do in a project is, in fact, pretty limited.
|
|
||||||
|
|
||||||
Using the lifecycle also makes it easier to call out to the artifact handlers.
|
|
||||||
|
|
||||||
+-----+
|
+-----+
|
||||||
|
|
||||||
%{snippet|id=lifecycle|url=http://cvs.apache.org/viewcvs.cgi/*checkout*/maven-components/maven-core/src/main/resources/META-INF/plexus/components.xml}
|
m2 <pluginId>:<mojoId>
|
||||||
|
|
||||||
+-----+
|
+-----+
|
||||||
|
|
||||||
|
These mojos that execute can be thought of as stand-alone tools, they may require dependency resolution
|
||||||
|
but aside from that they do not interact with any other mojos
|
||||||
|
|
||||||
|
Adding Mojos into the lifecycle
|
||||||
|
|
||||||
Here we are using antlr and it is known to maven that this plugin contributes to the generate-sources phase. In
|
Here we are using antlr and it is known to maven that this plugin contributes to the generate-sources phase. In
|
||||||
m1 the antlr plugin, in fact, worked by magic i.e. if there was a grammar present antlr would try to fire. This
|
m1 the antlr plugin, in fact, worked by magic i.e. if there was a grammar present antlr would try to fire. This
|
||||||
is a little too tricky and it would make sense to allow users to specify what they want fired as part of their
|
is a little too tricky and it would make sense to allow users to specify what they want fired as part of their
|
||||||
|
|
Loading…
Reference in New Issue