You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Goel, Deepak" <De...@intuit.com> on 2007/04/12 10:00:35 UTC

Reuse plug-in code

How can I reuse existing plug-in code in writing my own plug-in? For
example, I wanted to reuse the existing install plug-in and tried to
extend my plug-in from InstallMojo. Since source code of InstallMojo
wasn't present, the generated plugin.xml didn't contain the proper
dependencies. So when I tried to call a method in base class
(InstallMojo), I got a NullPointerException as the properties it needs
weren't injected.

 

Thanks,

 

Deepak Goel | Small Business Division, Intuit 

 


Re: Reuse plug-in code

Posted by franz see <fr...@gmail.com>.
Good day,

I'd suggest you checkout the source code of maven-install-plugin [1], change
its version to something like 2.2-goel. And then do your changes, and use
that by specifying in your pluginManagement the version of
maven-install-plugin to use ( this will also solve your problem of using
your maven-install-plugin in the  'default' lifecycle since you currently
cannot override the goals bound by default to the lifecycles ). 

And when you have the time, you may want to contribute your code back to the
community as others may find it useful as well :)

Cheers,
Franz

[1]
http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-install-plugin/


Jerome Lacoste-2 wrote:
> 
> On 4/12/07, Goel, Deepak <De...@intuit.com> wrote:
>> How can I reuse existing plug-in code in writing my own plug-in? For
>> example, I wanted to reuse the existing install plug-in and tried to
>> extend my plug-in from InstallMojo. Since source code of InstallMojo
>> wasn't present, the generated plugin.xml didn't contain the proper
>> dependencies. So when I tried to call a method in base class
>> (InstallMojo), I got a NullPointerException as the properties it needs
>> weren't injected.
> 
> I am not sure that it is possible to reuse plugins that way.
> 
> The plexus friendly code that wires the maven/POM information into the
> various properties doesn't seem to be reusable.
> 
> I usualy solve that by making the mojo to allow you to reuse the
> reusable part. E.g. by adding setters:
> 
> E.g.
> http://svn.codehaus.org/mojo/trunk/mojo/keytool-maven-plugin/src/main/java/org/codehaus/mojo/keytool/GenkeyMojo.java
> 
> Look at the bottom: these setters are not really required for plexus,
> but I use them for tests and to reuse the mojo into another plugin.
> 
> If there's a better way, I am all ears.
> 
> Jerome
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Reuse-plug-in-code-tf3564036s177.html#a9963386
Sent from the Maven - Users mailing list archive at Nabble.com.


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


Re: Reuse plug-in code

Posted by Jerome Lacoste <je...@gmail.com>.
On 4/12/07, Goel, Deepak <De...@intuit.com> wrote:
> How can I reuse existing plug-in code in writing my own plug-in? For
> example, I wanted to reuse the existing install plug-in and tried to
> extend my plug-in from InstallMojo. Since source code of InstallMojo
> wasn't present, the generated plugin.xml didn't contain the proper
> dependencies. So when I tried to call a method in base class
> (InstallMojo), I got a NullPointerException as the properties it needs
> weren't injected.

I am not sure that it is possible to reuse plugins that way.

The plexus friendly code that wires the maven/POM information into the
various properties doesn't seem to be reusable.

I usualy solve that by making the mojo to allow you to reuse the
reusable part. E.g. by adding setters:

E.g. http://svn.codehaus.org/mojo/trunk/mojo/keytool-maven-plugin/src/main/java/org/codehaus/mojo/keytool/GenkeyMojo.java

Look at the bottom: these setters are not really required for plexus,
but I use them for tests and to reuse the mojo into another plugin.

If there's a better way, I am all ears.

Jerome

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