You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by oliver <ol...@gmail.com> on 2011/01/11 21:55:56 UTC

How to inherit from another plugin?

Hi,

I derived a class from another plugin but the parameter were not initialized. What is the trick to get it initialized?

Example: this is the super class:

abstract public class AbstractAjcMojo extends AbstractMojo
{
    /**
     * The maven project.
     * 
     * @parameter expression="${project}"
     * @required @readonly
     */
    protected MavenProject project;
    ...

and this is my class:

public class XAjcCompileMojo extends AbstractAjcMojo {
    /**
     * The maven project.
     * 
     * @parameter expression="${project}"
     * @required @readonly
     */
    private MavenProject xproject;
    ...

"xproject" of the derived class is initialized by Plexus but not "project" from the super class. Why?

regards,
Oliver


Re: How to inherit from another plugin?

Posted by oliver <ol...@gmail.com>.
Hi Brett,

thanx - that was it. Now it works as expected.

regards,
Oliver


Am 11.01.2011 um 22:38 schrieb Brett Porter:

> If the code is in a different module to the plugin, you'll need to use the maven-inherit-plugin [1]. It should work if they are in the same plugin module.
> 
> (These questions can be directed at the users list in future)
> 
> - Brett
> 
> [1] http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/
> 
> On 12/01/2011, at 7:55 AM, oliver wrote:
> 
>> Hi,
>> 
>> I derived a class from another plugin but the parameter were not initialized. What is the trick to get it initialized?
>> 
>> Example: this is the super class:
>> 
>> abstract public class AbstractAjcMojo extends AbstractMojo
>> {
>>   /**
>>    * The maven project.
>>    * 
>>    * @parameter expression="${project}"
>>    * @required @readonly
>>    */
>>   protected MavenProject project;
>>   ...
>> 
>> and this is my class:
>> 
>> public class XAjcCompileMojo extends AbstractAjcMojo {
>>   /**
>>    * The maven project.
>>    * 
>>    * @parameter expression="${project}"
>>    * @required @readonly
>>    */
>>   private MavenProject xproject;
>>   ...
>> 
>> "xproject" of the derived class is initialized by Plexus but not "project" from the super class. Why?
>> 
>> regards,
>> Oliver
>> 
> 
> --
> Brett Porter
> brett@apache.org
> http://brettporter.wordpress.com/
> http://au.linkedin.com/in/brettporter
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
> 


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


Re: How to inherit from another plugin?

Posted by Brett Porter <br...@apache.org>.
If the code is in a different module to the plugin, you'll need to use the maven-inherit-plugin [1]. It should work if they are in the same plugin module.

(These questions can be directed at the users list in future)

- Brett

[1] http://www.ops4j.org/projects/pax/construct/maven-inherit-plugin/

On 12/01/2011, at 7:55 AM, oliver wrote:

> Hi,
> 
> I derived a class from another plugin but the parameter were not initialized. What is the trick to get it initialized?
> 
> Example: this is the super class:
> 
> abstract public class AbstractAjcMojo extends AbstractMojo
> {
>    /**
>     * The maven project.
>     * 
>     * @parameter expression="${project}"
>     * @required @readonly
>     */
>    protected MavenProject project;
>    ...
> 
> and this is my class:
> 
> public class XAjcCompileMojo extends AbstractAjcMojo {
>    /**
>     * The maven project.
>     * 
>     * @parameter expression="${project}"
>     * @required @readonly
>     */
>    private MavenProject xproject;
>    ...
> 
> "xproject" of the derived class is initialized by Plexus but not "project" from the super class. Why?
> 
> regards,
> Oliver
> 

--
Brett Porter
brett@apache.org
http://brettporter.wordpress.com/
http://au.linkedin.com/in/brettporter





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