Issue Details (XML | Word | Printable)

Key: MNG-2188
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: John Casey
Reporter: Vincent Massol
Votes: 0
Watchers: 1
Operations

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

Report mojos should check canGenerateReport() when called directly

Created: 29/Mar/06 09:48 AM   Updated: 14/Aug/07 02:30 PM   Resolved: 14/Aug/07 02:30 PM
Component/s: Sites & Reporting
Affects Version/s: 2.0.3
Fix Version/s: 2.0.8

Time Tracking:
Not Specified

File Attachments: 1. Text File AbstractMavenReport-canGenerateReport-check.patch (0.8 kB)


Complexity: Intermediate
Patch Submitted: Yes


 Description  « Hide

There's a canGenerateReport() method in a ReportMojo. This method is called by the site phase to decide if the mojo should be called or not. This is cool. However the user can call directly the report mojo and in that case the canGenerateReport() method is not called automatically. Thus the solution for a plugin developer is to write:

public void executeReport()
{
    if (canGenerateReport() )
    { 
        [...]
    }
}

Which means that the canGenerateReport method is going to be called twice when mvn site is executed.



Walco van Loon added a comment - 04/Apr/06 04:43 PM

Patch for AbstractMavenReport to perform canGenerateReport() when it's called directly.


Jason van Zyl added a comment - 02/Jun/07 04:01 PM

Already dealt with as report mojos can only be called by a report document renderer.


Vincent Massol added a comment - 02/Jun/07 04:14 PM

hmm... so does it mean users cannot call, say, mvn clover:clover anymore?


Brett Porter added a comment - 03/Jun/07 07:10 PM

Vincent, I think your patch is correct. What the report document renderer does is irrelevant to clover:clover type executions. I'd suggest reopening and applying your own patch


John Casey added a comment - 14/Aug/07 02:30 PM

I added this logic to the generate() method, since the execute method seems to disallow direct invocation at this point.