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

Key: MNG-1886
Type: Improvement Improvement
Status: Reopened Reopened
Priority: Major Major
Assignee: Unassigned
Reporter: Vincent Massol
Votes: 1
Watchers: 0
Operations

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

Need way to share code between report mojos and main build mojos

Created: 21/Dec/05 02:33 PM   Updated: 12/Jun/08 06:31 PM
Component/s: Plugin API
Affects Version/s: 2.0.1
Fix Version/s: 3.x

Time Tracking:
Not Specified

Complexity: Intermediate


 Description  « Hide
For example in the clover plugin i have both report mojos and main build mojos. They need to share lots of configuration elements and common methods but it's not easy to do so because each type needs to extend either AbstractMavenReport or AbstractMojo. Of course I could not extend AbstractMavenReport and instead implement the interface but then I'll have to reimplement all its methods.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Brett Porter - 28/Dec/05 07:00 AM
can you elaborate on what you mean here?

If they are sharing types - there is no reason this can't be done with a subelement (eg, like MavenArchiveConfiguration in jar, war, etc).

Other things might be sharable by the plugin context.

Please reopen if neither of these address your needs.


Vincent Massol - 28/Dec/05 07:15 AM
I'm talking about sharing configuration elements (fields).

Here's an example:

<configuration>
<cloverDatabase>...</cloverDatabase>
<jdk>...</jdk>
[...]

Is there any doc on the plugin context? I don't think this is what I'm after though.

Try writing a plugin which has both reporting mojos and main mojos and you'll see what I mean. Alternatively you could have a look at the clover plugin. Search for MNG-1886 in the code and you'll find the places where it's awkward and would ideally require a better design.

This is an issue about code duplication, maintenance and consistency in general. I think the issue's title can be changed to; "How to share configuration elements between mojos when inheritance is not possible".

The example you give about the MavenArchiveConfiguration require the introduction of another level of configuration for users. I'm talking about sharing the top level.

Thanks


Brett Porter - 28/Dec/05 07:25 AM
ok, there's something else here. I guess its going to be something like MavenArchiveConfiguration, but with a @parameter nested="false" or something like that. Won't be done before 2.1 if at all.

As a side note, AbstractMavenReport already extends AbstractMojo so you can achieve this anyway, but it means making a report of your mojo. A bit ugly.

I think there is an overall need to improve configurability of plugins (eg, validation of elements inside nested types, more sharing, etc).