You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Kalpak Gadre <ka...@gmail.com> on 2011/05/30 16:58:06 UTC

Reusing existing Mojo in a custom Mojo

Hi,

I am developing a Mojo for manipulation of JIRA while making a release. 
This mojo is required to manipulate issues and generate release notes. 
The process is very specific to the client. As part of the process, I 
need to commit the newly generated release notes to SCM. I also need to 
ensure that there are no local changes in project (similar to 
release:prepare)

How can I utilize existing functionality of scm:status and scm:commit 
mojos? I tried extending the AbstractScmMojo from maven-scm-plugin to 
get handle to the ScmManager object. Since most of the code was already 
in place at AbstractScmMojo it made sense to extend my Mojo from this 
class, No?

With this approach though, my Mojo fails with,

Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to 
create SCM repository.
     at 
in.firestart.maven.plugins.release.JiraReleasePrepareMojo.execute(JiraReleasePrepareMojo.java:78)
     at 
org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
     at 
org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
     ... 19 more
Caused by: org.apache.maven.scm.ScmException: Can't load the scm provider.
     at 
org.apache.maven.scm.plugin.AbstractScmMojo.getScmRepository(AbstractScmMojo.java:362)
     at 
in.firestart.maven.plugins.release.JiraReleasePrepareMojo.execute(JiraReleasePrepareMojo.java:68)
     ... 21 more
Caused by: java.lang.NullPointerException: You need to define a 
connectionUrl parameter
     at 
org.apache.maven.scm.plugin.AbstractScmMojo.getConnectionUrl(AbstractScmMojo.java:249)
     at 
org.apache.maven.scm.plugin.AbstractScmMojo.getScmRepository(AbstractScmMojo.java:298)
     ... 22 more

The scm connection and developerConnection both are configured correctly 
and mvn scm:status works perfectly well on the same project. Looking at 
the error, it looks like plexus is not wiring the connectionUrl 
attribute. I am a noob at writing Mojos and plexus in general. Do we 
need to explicitly request Plexus to inject components into our Mojo? 
Please advice.

Here is my environment,

maven-scm-plugin version: 1.5
Maven version: 3.0.3

Thanks,

Kalpak

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


Re: Reusing existing Mojo in a custom Mojo

Posted by Kalpak Gadre <ka...@gmail.com>.
Thanks Stephen and Leonard.


> due to how maven plugin plugin works, you cannot have a dependency on 
> a maven plugin and extend the mojo's in that plugin.
>
> when we switch from javadoc processing to annotation processing, and 
> with the classloader from maven 3 it will be possible, but until then 
> you need to copy the mojo into your own plugin... this is why a lot of 
> the maven plugins are thing wrappers on the jar providing the 
> functionality (also gives you an easier route off maven id you ever 
> want one)
>
> - Stephen
>
> ---
> Sent from my Android phone, so random spelling mistakes, random 
> nonsense words and other nonsense are a direct result of using swype 
> to type on the screen
>
> On 30 May 2011 18:19, "Leonard Ehrenfried" <leonard.ehrenfried@web.de 
> <ma...@web.de>> wrote:


Re: Reusing existing Mojo in a custom Mojo

Posted by Stephen Connolly <st...@gmail.com>.
due to how maven plugin plugin works, you cannot have a dependency on a
maven plugin and extend the mojo's in that plugin.

when we switch from javadoc processing to annotation processing, and with
the classloader from maven 3 it will be possible, but until then you need to
copy the mojo into your own plugin... this is why a lot of the maven plugins
are thing wrappers on the jar providing the functionality (also gives you an
easier route off maven id you ever want one)

- Stephen

---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 30 May 2011 18:19, "Leonard Ehrenfried" <le...@web.de>
wrote:

Re: Reusing existing Mojo in a custom Mojo

Posted by Leonard Ehrenfried <le...@web.de>.
I'm by no means an accomplished Mojo author but I have learned the most by
simply copying an existing Mojo and chipping away the existing code until I
understood what each part did and how.

In your case I would simply take the working StatusMojo.java (?) as a whole
and throw out the code you don't need. Don't forget to include the scm
plugin as dependency of your plugin.

Lenni


On Mon, May 30, 2011 at 4:58 PM, Kalpak Gadre <ka...@gmail.com> wrote:

> Hi,
>
> I am developing a Mojo for manipulation of JIRA while making a release.
> This mojo is required to manipulate issues and generate release notes. The
> process is very specific to the client. As part of the process, I need to
> commit the newly generated release notes to SCM. I also need to ensure that
> there are no local changes in project (similar to release:prepare)
>
> How can I utilize existing functionality of scm:status and scm:commit
> mojos? I tried extending the AbstractScmMojo from maven-scm-plugin to get
> handle to the ScmManager object. Since most of the code was already in place
> at AbstractScmMojo it made sense to extend my Mojo from this class, No?
>
> With this approach though, my Mojo fails with,
>
> Caused by: org.apache.maven.plugin.MojoExecutionException: Failed to create
> SCM repository.
>    at
> in.firestart.maven.plugins.release.JiraReleasePrepareMojo.execute(JiraReleasePrepareMojo.java:78)
>    at
> org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
>    at
> org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
>    ... 19 more
> Caused by: org.apache.maven.scm.ScmException: Can't load the scm provider.
>    at
> org.apache.maven.scm.plugin.AbstractScmMojo.getScmRepository(AbstractScmMojo.java:362)
>    at
> in.firestart.maven.plugins.release.JiraReleasePrepareMojo.execute(JiraReleasePrepareMojo.java:68)
>    ... 21 more
> Caused by: java.lang.NullPointerException: You need to define a
> connectionUrl parameter
>    at
> org.apache.maven.scm.plugin.AbstractScmMojo.getConnectionUrl(AbstractScmMojo.java:249)
>    at
> org.apache.maven.scm.plugin.AbstractScmMojo.getScmRepository(AbstractScmMojo.java:298)
>    ... 22 more
>
> The scm connection and developerConnection both are configured correctly
> and mvn scm:status works perfectly well on the same project. Looking at the
> error, it looks like plexus is not wiring the connectionUrl attribute. I am
> a noob at writing Mojos and plexus in general. Do we need to explicitly
> request Plexus to inject components into our Mojo? Please advice.
>
> Here is my environment,
>
> maven-scm-plugin version: 1.5
> Maven version: 3.0.3
>
> Thanks,
>
> Kalpak
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>