maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stuart McCulloch" <>
Subject Re: Extending Maven2 plugins
Date Thu, 21 Feb 2008 03:45:09 GMT
On 21/02/2008, Julien Stern <> wrote:
> Hi list,
> I just tried to "extend" a plugin, by creating a local plugin
> with a Mojo that extends (in the Java sense) an other Mojo
> from an existing plugin.
> It overrides the execute method and calls several "super" methods
> along with doing its own work.
> However, when I try to execute the plugin, none of the "parameters"
> seem to be set and I keep on getting NullPointerExceptions.
> For instance, "project", as defined below in a super class in "null".
>         /**
>          * POM.
>          *
>          * @parameter expression="${project}"
>          * @readonly
>          * @required
>          */
>         protected MavenProject project;
> It that a bug? Is there a way to do want I'm trying to do?

Hi Julien,

when you build a maven plugin, the [plugin:descriptor] goal generates an XML
to target/classes/META-INF/maven/plugin.xml that tells the plexus container
fields need to be injected, and where to get them from (along with defaults,

unfortunately, the tool used to generate the plugin.xml works on javadoc
which means that when you extend a mojo from another project, it doesn't see
source (and therefore the javadoc) and doesn't add the fields to the

this means when you come to use the extended mojo, a lot of the fields will
be null.

I do have a tool (another maven plugin) that will help add inherited fields
and goals
to the plugin.xml, which is documented here (may upload it to repo1 if it's

however, you do need to have the plugin being extended as a dependency in
new plugin project, and some people have said this is not necessarily a good

btw, if you have commit access to both codebases, another solution is to
the common code into a plexus component that can then be used in both


> --
> Julien
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Cheers, Stuart

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message