History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: MNG-3042
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Leopoldo Agdeppa III
Votes: 8
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Maven 2

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.

Created: 08/Jun/07 04:38 AM   Updated: 18/Mar/08 06:55 PM
Component/s: Plugin API
Affects Version/s: None
Fix Version/s: 3.0

Time Tracking:
Not Specified

Issue Links:
Related
 


 Description  « Hide
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

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Jörg Hohwiller - 29/Aug/07 04:53 AM
I have the same problem/need.

Marvin Froeder - 24/Sep/07 08:38 AM
On the same boat...

Have the same need too.



Petar Tahchiev - 31/Dec/07 08:38 AM
I have the same problem - I want to extend the surefire plugin and every time I run it, I get a null-pointer exception, because the instant variables are null. According to maven-inherit plugin I have to propagate the fields using reflection. Well, propagation in my case does not work, because the fields in the surefire plugin are all private , and I get a:

can not access a member of class org.apache.maven.plugin.surefire.SurefirePlugin with modifiers "private"

exception.

Any other suggestions?


Stuart McCulloch - 20/Feb/08 09:57 PM
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.


Brian Fox - 07/Mar/08 07:54 PM
inheriting mojos across plugins is not currently supported. We should consider for 2.1

Andrew Lee Rubinger - 18/Mar/08 06:55 PM
Would appreciate the implementation to use annotations with retention=RUNTIME.

S,
ALR