[
https://issues.apache.org/jira/browse/MNG-3508?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16666218#comment-16666218
]
Paul Benedict edited comment on MNG-3508 at 10/27/18 9:37 PM:
--------------------------------------------------------------
I am reopening this ticket. This request seems perfectly reasonable. As
evidenced by the many "how to" questions on the web, it is a frequently
encountered problem without a perfect solution. Prime example is from [Brian's
Sonatype blog
post|https://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/],
and there are others I could cite (lots on Stack Overflow), but please see for
yourself by searching "maven plugin run once".
Here is my use case. This is a real example from a custom plugin:
# Plugin manages an external resource.
# Plugin gets management configuration from the session (somewhere in the
project hierarchy) in the form of properties.
# Plugin must validly operate when bound to a phase.
# Plugin must validly operate when directly executed from CLI.
# Plugin must validly operate from any execution root in a multi-module build.
# Plugin must execute only once per build (especially important in conjunction
with #5).
At this moment only custom solutions exist – code yourself a workaround/hack.
An official solution would be welcomed.
PS: It doesn't seem {{@Mojo(executionStrategy = "once-per-session")}}
accomplishes this. That's surprising to me because, at least on its face, the
attribute name seems to suggest it? Since my plugin runs in every project of a
multi-module build, I suppose that means each project gets a new session?
was (Author: paul4christ79):
I am reopening this ticket. This request seems perfectly reasonable. As
evidenced by the many "how to" questions on the web, it is a frequently
encountered problem without a perfect solution. Prime example is from [Brian's
Sonatype blog
post|https://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/],
and there are others I could site (lots on Stack Overflow). but please see for
yourself by searching "maven plugin run once".
Here is my use case. This is a real example from a custom plugin:
# Plugin manages an external resource.
# Plugin gets management configuration from the session (somewhere in the
project hierarchy) in the form of properties.
# Plugin must validly operate when bound to a phase.
# Plugin must validly operate when directly executed from CLI.
# Plugin must validly operate from any execution root in a multi-module build.
# Plugin must execute only once per build (especially important in conjunction
with #5).
At this moment only custom solutions exist – code yourself a workaround/hack.
An official solution would be welcomed.
PS: It doesn't seem {{@Mojo(executionStrategy = "once-per-session")}}
accomplishes this. That's surprising to me because, at least on its face, the
attribute name seems to suggest it? Since my plugin runs in every project of a
multi-module build, I suppose that means each project gets a new session?
> Allow 'once' configuration item on plugin execution
> ---------------------------------------------------
>
> Key: MNG-3508
> URL: https://issues.apache.org/jira/browse/MNG-3508
> Project: Maven
> Issue Type: New Feature
> Reporter: Ittay Dror
> Priority: Major
>
> Scenario:
> - parent pom defines modules A, B
> - it also defines a plugin with some execution
> - when it runs, the plugin runs 3 times (for parent, A, B)
> Now, I can set 'inherited' to false, but then if I just run 'A', the plugin
> won't execute.
> What I'd like is to be able to configure the execution to run 'once' in the
> lifecycle. This is useful mainly for plugins that do some kind of setup,
> initialization or validation, which in many cases need to be done once per
> execution.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)