Issue Details (XML | Word | Printable)

Key: MNG-3062
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: John Casey
Reporter: Paul Gier
Votes: 0
Watchers: 0
Operations

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

Allow access to mojoExecution from within plugin.

Created: 19/Jun/07 03:01 PM   Updated: 14/Aug/07 10:35 AM
Component/s: None
Affects Version/s: 2.0.6
Fix Version/s: 2.0.8, 3.0-alpha-1

Time Tracking:
Not Specified

File Attachments: 1. Text File PluginParameterExpressionEvaluator.patch (0.8 kB)


Patch Submitted: Yes


 Description  « Hide
I would like to be able to access the execution ID from within a plugin. This could be useful for example to run only certain executions. This could be done with a small change to the plugin expression evaluator.
I created a patch that would give the plugin access to the current MojoExecution.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Brett Porter added a comment - 20/Jun/07 09:32 PM
thinking about whether this is a good idea... it is probably not harmful, but I'm not sure if it would also be a best practice not to use it.

What is the use case you have? If the executions are structured appropriately, I would think the mojo just runs or not, and the configuration can be used to alter behaviour.


Paul Gier added a comment - 21/Jun/07 10:15 AM
My use case is basically what I said in the description. I would like to be able to call only certain executions of the surefire plugin. I'm currently accomplishing something similar using profiles, but it seemed like there should be an easier way to just call an execution. I was thinking that if the plugin had access to the execution id you could do something like:
mvn test -Dmaven.test.execution1

Then the plugin could check the property to see if it should run or not. Not sure if this is the best way to do it, but it is one idea.

Another idea would be to just add the execution ID to the plugin API, and set it when the plugin is initialized, maybe in the same place the log is initialized. But I thought there might be other useful information in the mojoExecution object.


John Casey added a comment - 14/Aug/07 10:35 AM
I applied this. It provides easy access to all sorts of information about the current mojo, execution, and plugin...including configuration and more. This will be very useful for advanced mojos and reports.