You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Stuart McCulloch (JIRA)" <ji...@codehaus.org> on 2008/02/21 04:57:28 UTC

[jira] Commented: (MNG-3042) Extending a Mojo Class and used in a new Mojo Project, parameter fields in the parent mojo are not set, this disables reuse of existing mojo project.

    [ http://jira.codehaus.org/browse/MNG-3042?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_124544 ] 

Stuart McCulloch commented on MNG-3042:
---------------------------------------

FYI, you only need to propagate values using reflection if you override the field, ie. you declare a field in your mojo that "hides" a field of the same name in original mojo. You only usually need to do this if you need to change the default, or want access to the field - although in the latter case you could use reflection to read the field rather than override it. ( interestingly, if the overridden field is a @parameter then your new field will be injected instead of the original - but if it's an @component then it appears the original field is injected rather than the original )

Note that you can read and write private fields using reflection - you just need to use setAccessible(true) on the field to make it accessible, as shown in:

   http://www.ops4j.org/projects/pax/construct/maven-pax-plugin/xref/org/ops4j/pax/construct/util/ReflectMojo.html

btw, in the maven-pax-plugin I extend a number of different mojos and override a couple of private fields, so I know this works in practice.


> Extending a Mojo Class and used in a new Mojo Project, parameter fields in the parent mojo are not set, this disables reuse of existing mojo project.
> -----------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: MNG-3042
>                 URL: http://jira.codehaus.org/browse/MNG-3042
>             Project: Maven 2
>          Issue Type: Bug
>          Components: Plugin API
>            Reporter: Leopoldo Agdeppa III
>             Fix For: Reviewed Pending Version Assignment
>
>
> I have an Existing maven-plugin-a and I want to extend its functionality and put it in maven-plugin-b, so what i did is I put the the maven-plugin-a as a dependecy in maven-plugin-b and extended the mojo class from A, the issue on this is that paramter fields from A is not set, when I used plugin-B, I think this disables reusing and extending of mojos

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira