Maven
  1. Maven
  2. MNG-3062

Allow access to mojoExecution from within plugin.

    Details

    • Type: Improvement Improvement
    • Status: 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
    • Flags:
      Patch

      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

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        55d 19h 34m 1 John Casey 14/Aug/07 11:35
        Mark Thomas made changes -
        Workflow jira [ 12950396 ] Default workflow, editable Closed status [ 12986597 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 21:45:26 UTC 2015 [ 1428270326204 ]
        Mark Thomas made changes -
        Patch Submitted Yes [ 10763 ]
        Flags Patch [ 10430 ]
        Mark Thomas made changes -
        Workflow jira [ 12713557 ] Default workflow, editable Closed status [ 12753344 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 08:49:45 UTC 2015 [ 1428223785911 ]
        John Casey made changes -
        Fix Version/s 2.0.8 [ 13139 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 2.1-alpha-1 [ 13143 ]
        Fix Version/s 2.0.x [ 13141 ]
        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.
        John Casey made changes -
        Assignee John Casey [ jdcasey ]
        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.
        Brett Porter made changes -
        Field Original Value New Value
        Fix Version/s 2.0.x [ 13141 ]
        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.
        Paul Gier created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development