You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Andrew Waterman <aw...@ecosur.mx> on 2010/10/28 17:19:41 UTC

Help! Mojo development Issue

I'm not sure if this is the right forum for this, but I thought I would try here first. 

I have a plugin that I am trying to develop that wants to resolve a set of groupId/artifactId pairs to resolved artifacts in the MavenProject it is executing from.  I have annotated the dependent field in the following way:

    /*
        @required
        @parameter default-value="${project}"
    */
    public MavenProject project;

When I try and run my unit test (extending from the "AbstractMojoTestCase") I get a NPE when I try and access the "project" class variable.  When I look at this in the debugger, I can see that the project field was never set; although all other custom fields that have been set in the test pom are showing up correctly.  

Any ideas?

I'm also seeing this issue when I attempt to use the "@component" tag.

Thanks!

best wishes,

Andrew 

Re: Help! Mojo development Issue

Posted by Justin Edelson <ju...@justinedelson.com>.
All I can suggest is to look at the source of that maven-hudson-project. I've written a number of Maven plugins, but I believe that's the case where I used AbstractMojoTestCase the most.

It's been a while, but I seem to remember figuring out AbstractMojoTestCase by looking at other plugins which used it, although I can't remember which ones. That's generally what I do with Maven plugin development anyway - find a plugin which does something comparable to what I'm trying to do.

Justin

On Oct 28, 2010, at 4:25 PM, Andrew Waterman wrote:

> Thank you so very much for the reply Justin.
> 
> I'll go ahead and provide an implementation stub in the project tab to a class that extends "MavenProjectStub"; following your example for Hudson.  This setup is just for the AbstractMojoTestCase, right?  Presumably, normal poms don't need this stub for the plugin to function, I hope.
> 
> Do you know of anymore documentation around that project?  For example, my jUnit tests are runnable, but do not execute as part of the build cycle, which I'd love to know how to fix.
> 
> best wishes,
> 
> Andrew
> 
> On Oct 28, 2010, at 10:58 AM, Justin Edelson wrote:
> 
>> IIRC, you need to declare the project field and provide an implementation class.
>> 
>> See, for example, http://github.com/justinedelson/maven-hudson-plugin/blob/master/src/test/resources/unit/pom-with-local-ci.xml
>> 
>> That code worked at some point...
>> 
>> HTH,
>> Justin
>> 
>> 
>> On Oct 28, 2010, at 11:19 AM, Andrew Waterman wrote:
>> 
>>> I'm not sure if this is the right forum for this, but I thought I would try here first. 
>>> 
>>> I have a plugin that I am trying to develop that wants to resolve a set of groupId/artifactId pairs to resolved artifacts in the MavenProject it is executing from.  I have annotated the dependent field in the following way:
>>> 
>>>  /*
>>>      @required
>>>      @parameter default-value="${project}"
>>>  */
>>>  public MavenProject project;
>>> 
>>> When I try and run my unit test (extending from the "AbstractMojoTestCase") I get a NPE when I try and access the "project" class variable.  When I look at this in the debugger, I can see that the project field was never set; although all other custom fields that have been set in the test pom are showing up correctly.  
>>> 
>>> Any ideas?
>>> 
>>> I'm also seeing this issue when I attempt to use the "@component" tag.
>>> 
>>> Thanks!
>>> 
>>> best wishes,
>>> 
>>> Andrew
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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


Re: Help! Mojo development Issue

Posted by Andrew Waterman <aw...@ecosur.mx>.
Thank you so very much for the reply Justin.

I'll go ahead and provide an implementation stub in the project tab to a class that extends "MavenProjectStub"; following your example for Hudson.  This setup is just for the AbstractMojoTestCase, right?  Presumably, normal poms don't need this stub for the plugin to function, I hope.

Do you know of anymore documentation around that project?  For example, my jUnit tests are runnable, but do not execute as part of the build cycle, which I'd love to know how to fix.

best wishes,

Andrew

On Oct 28, 2010, at 10:58 AM, Justin Edelson wrote:

> IIRC, you need to declare the project field and provide an implementation class.
> 
> See, for example, http://github.com/justinedelson/maven-hudson-plugin/blob/master/src/test/resources/unit/pom-with-local-ci.xml
> 
> That code worked at some point...
> 
> HTH,
> Justin
> 
> 
> On Oct 28, 2010, at 11:19 AM, Andrew Waterman wrote:
> 
>> I'm not sure if this is the right forum for this, but I thought I would try here first. 
>> 
>> I have a plugin that I am trying to develop that wants to resolve a set of groupId/artifactId pairs to resolved artifacts in the MavenProject it is executing from.  I have annotated the dependent field in the following way:
>> 
>>   /*
>>       @required
>>       @parameter default-value="${project}"
>>   */
>>   public MavenProject project;
>> 
>> When I try and run my unit test (extending from the "AbstractMojoTestCase") I get a NPE when I try and access the "project" class variable.  When I look at this in the debugger, I can see that the project field was never set; although all other custom fields that have been set in the test pom are showing up correctly.  
>> 
>> Any ideas?
>> 
>> I'm also seeing this issue when I attempt to use the "@component" tag.
>> 
>> Thanks!
>> 
>> best wishes,
>> 
>> Andrew
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 


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


Re: Help! Mojo development Issue

Posted by Justin Edelson <ju...@justinedelson.com>.
IIRC, you need to declare the project field and provide an implementation class.

See, for example, http://github.com/justinedelson/maven-hudson-plugin/blob/master/src/test/resources/unit/pom-with-local-ci.xml

That code worked at some point...

HTH,
Justin


On Oct 28, 2010, at 11:19 AM, Andrew Waterman wrote:

> I'm not sure if this is the right forum for this, but I thought I would try here first. 
> 
> I have a plugin that I am trying to develop that wants to resolve a set of groupId/artifactId pairs to resolved artifacts in the MavenProject it is executing from.  I have annotated the dependent field in the following way:
> 
>    /*
>        @required
>        @parameter default-value="${project}"
>    */
>    public MavenProject project;
> 
> When I try and run my unit test (extending from the "AbstractMojoTestCase") I get a NPE when I try and access the "project" class variable.  When I look at this in the debugger, I can see that the project field was never set; although all other custom fields that have been set in the test pom are showing up correctly.  
> 
> Any ideas?
> 
> I'm also seeing this issue when I attempt to use the "@component" tag.
> 
> Thanks!
> 
> best wishes,
> 
> Andrew


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