Maven 2 & 3

Report mojos should check canGenerateReport() when called directly

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 2.0.3
  • Fix Version/s: 2.0.8
  • Component/s: Sites & Reporting
  • Labels:
    None
  • Complexity:
    Intermediate
  • Patch Submitted:
    Yes
  • Number of attachments :
    1

Description

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.

Activity

Hide
Walco van Loon added a comment -

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

Show
Walco van Loon added a comment - Patch for AbstractMavenReport to perform canGenerateReport() when it's called directly.
Hide
Jason van Zyl added a comment -

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

Show
Jason van Zyl added a comment - Already dealt with as report mojos can only be called by a report document renderer.
Hide
Vincent Massol added a comment -

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

Show
Vincent Massol added a comment - hmm... so does it mean users cannot call, say, mvn clover:clover anymore?
Hide
Brett Porter added a comment -

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

Show
Brett Porter added a comment - 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
Hide
John Casey added a comment -

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

Show
John Casey added a comment - I added this logic to the generate() method, since the execute method seems to disallow direct invocation at this point.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: