You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Rahul <ra...@clear.net.nz> on 2005/06/18 11:28:07 UTC

[m2] Plugin Descriptor Vs. Mojo Descriptor

Hi,

Could anyone please clarify my following doubts:
a) What's the difference between a Plugin Descriptor and Mojo Descriptor?
b) If these are different, then, how and when are these being created 
(using annotations and xdoclet?) and what role do these play in lifecyle 
of a plugin? I did notice a BSH script for extracting annotations to a 
Descriptor, but I don't think this is the only strategy that could be used.
c) The lifecyle document says in "Plugins" section:

<snip>
For example, the Modello plugin always binds modello:java to the 
generate-sources phase.
</snip>
 - where is it specified that the Modello plugin always binds to 
"generate-sources" phase?

Appreciate any notes/pointers to help me understand plugins - thanks !

Cheers,
Rahul




---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: [m2] Plugin Descriptor Vs. Mojo Descriptor

Posted by Trygve Laugstøl <tr...@student.matnat.uio.no>.
On Sat, Jun 18, 2005 at 09:28:07PM +1200, Rahul wrote:
> Hi,
> 
> Could anyone please clarify my following doubts:
> a) What's the difference between a Plugin Descriptor and Mojo Descriptor?

A plugin is a set of mojos and other classes. A mojo can be called as a
goal. The plugin descriptor describes the entire plugin, including a set
of mojos, the plugins dependencies (that's how Maven can download the
dependencies of a plugin without the pom), the plugins id and some misc
other stuff. Take a look at
maven-plugins/maven-jar-plugin/target/classes/META-INF/maven/plugin.xml
for a example plugin descriptor. You'll see the mojos descripbed there
aswell.

> b) If these are different, then, how and when are these being created 
> (using annotations and xdoclet?) and what role do these play in lifecyle 
> of a plugin? I did notice a BSH script for extracting annotations to a 
> Descriptor, but I don't think this is the only strategy that could be used.

Inside /maven-plugin-tools there are plugin source processors that are
used by the plugin plugin to generate the descriptor. The Java plugin
descriptor uses QDox[1] to look for @tags in the source code. QDox is the
source processing core of XDoclet 2.

> c) The lifecyle document says in "Plugins" section:
> 
> <snip>
> For example, the Modello plugin always binds modello:java to the 
> generate-sources phase.
> </snip>
> - where is it specified that the Modello plugin always binds to 
> "generate-sources" phase?

Look in [2] and you'll see: 

/**
 * @goal java
 *
 * @phase generate-sources
 *
 * @description Creates java beans from the Modello model.

As this is from the modello-maven-plugin the "@goal java" part is what connects
the mojo class and the modello:java part and the "@phase generate-sources"
tells what phase the goal should be executed in. Note that while @goal is
required @phase is not. If you don't specify a @phase the plugin won't be
executed as a part of the normal build lifecycle and will have to be called
explicitly. clean:clean is another mojo that doesn't bind to a lifecycle.

To check out the Modello sources:

 $ svn co svn+ssh://svn.codehaus.org/home/projects/modello/scm/trunk -d modello

> Appreciate any notes/pointers to help me understand plugins - thanks !

[1]: http://qdox.codehaus.org
[2]: http://cvs.modello.codehaus.org/modello/modello-maven-plugin/src/main/java/org/codehaus/modello/maven/ModelloJavaMojo.java?rev=1.2&view=auto

--
Trygve