views:

65

answers:

1

When I make one plugin extend another it normally inherits the properties from the parent. Sometimes it doesn't work though. When the plugin is loaded up, the properties from the parent are all null

What might I be doing wrong? I package my project as a maven-plugin and it builds ok.

+1  A: 

I've seen this myself and it drove me mad until I debugged the Plexus internals. I'm guessing the properties are not inherited when the parent is in another plugin?

If that is the case, the explanation below will help. If it is not, it might be a typo in the Javadoc annotations. Maven will skip any tags it doesn't recognise without warning.

If it's neither of these, can you post a little more detail? perhaps an example of the failing Mojo?


If the parent is in another project, here's the reason why you're having problems.

Maven plugins use Javadoc annotations to define the dependencies, goal declarations, and other configurations (Maven 2.1 introduced proper Java annotations but hardly any plugins use them yet). Once the plugin has been installed/deployed the Javadoc is lost, so any plugin that extends a plugin in another jar won't have access to the plexus-defined properties in the parent.

There is a workaround though. The plugin metadata is output to META-INF/maven/plugin.xml. There is a third-party plugin that reads the information from the parent Mojo's plugin.xml and merges the local plugin metadata with it. Your plugin should then work as normal.

Rich Seller
took some figuring out what you meant by "this is the explanation"
talk to frank
reworded to make some sense
Rich Seller