Maven 2 & 3
  1. Maven 2 & 3
  2. MNG-3062

Allow access to mojoExecution from within plugin.

    Details

    • Type: Improvement Improvement
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.6
    • Fix Version/s: 2.0.8, 3.0-alpha-1
    • Component/s: None
    • Labels:
      None
    • Patch Submitted:
      Yes
    • Number of attachments :
      1

      Description

      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.

        Activity

        Hide
        Brett Porter added a comment -

        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.

        Show
        Brett Porter added a comment - 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.
        Hide
        Paul Gier added a comment -

        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.

        Show
        Paul Gier added a comment - 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.
        Hide
        John Casey added a comment -

        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.

        Show
        John Casey added a comment - 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.

          People

          • Assignee:
            John Casey
            Reporter:
            Paul Gier
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: