Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Francois MAROT
Hi all & happy new year !I have a question regarding plugin development.I
have made a custom plugin and would like to make it's Mojo executed once
*and only once* in my whole reactor build.If I include it in my parent pom
(not in pluginManagement), then by default it is executed once at the root
and once in child-modules. Solutions I found out:- false used in plugin
declaration in pom => it sorta do what I want BUT my plugin is not executed
once if I invke the maven build directly inside a child-module.- aggregator
= true in the @Mojo annotation => I thought it was THE solution but I can't
seem to understand what it does: despite declaring my mojo an aggregator, it
is executed in all children.-
http://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/
=> the solution given there does not really satisfies me because it means
Maven WILL call my execute() method more than once, simply my plugin will
bypass it except at the execution root. We can do better than that can't we
?!I really can't understand why the aggregator parameter does not work as I
expected it to.Any idea ?François



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Francois MAROT
[Sorry, re-posting with correct formatting]

Hi all & happy new year !
I have a question regarding plugin development.

I have made a custom plugin and would like to make it's Mojo executed once
*and only once* in my whole reactor build. If I include it in my parent pom
(not in pluginManagement), then by default it is executed once at the root
and once in child-modules.

Solutions I found out:

- <inherited>false</inherited> used in plugin declaration in pom => it sorta
do what I want
BUT my plugin is not executed once if I invoke the maven build directly
inside a child-module.

- aggregator = true in the @Mojo annotation => I thought it was THE solution
but I can't
seem to understand what it does: despite declaring my mojo an aggregator, it
is executed in all children.

-
http://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-build/
=> the solution given there does not really satisfies me because it means
Maven WILL call my execute() method more than once, simply my plugin will
bypass it except at the execution root. We can do better than that can't we
?!

I really can't understand why the aggregator parameter does not work as I
expected it to.
Any idea ?

François



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Hervé BOUTEMY
Hi François,

Happy New Year!

Can you check in generated META-INF/maven/plugin.xml descriptor that your
annotation in source was well detected?
Because it looks like a typo somewhere in your plugin: if you can share the
code (eventually privately), perhaps new eyes can find it.

Regards,

Hervé

Le vendredi 5 janvier 2018, 14:36:07 CET Francois MAROT a écrit :

> [Sorry, re-posting with correct formatting]
>
> Hi all & happy new year !
> I have a question regarding plugin development.
>
> I have made a custom plugin and would like to make it's Mojo executed once
> *and only once* in my whole reactor build. If I include it in my parent pom
> (not in pluginManagement), then by default it is executed once at the root
> and once in child-modules.
>
> Solutions I found out:
>
> - <inherited>false</inherited> used in plugin declaration in pom => it sorta
> do what I want
> BUT my plugin is not executed once if I invoke the maven build directly
> inside a child-module.
>
> - aggregator = true in the @Mojo annotation => I thought it was THE solution
> but I can't
> seem to understand what it does: despite declaring my mojo an aggregator, it
> is executed in all children.
>
> -
> http://blog.sonatype.com/2009/05/how-to-make-a-plugin-run-once-during-a-buil
> d/ => the solution given there does not really satisfies me because it means
> Maven WILL call my execute() method more than once, simply my plugin will
> bypass it except at the execution root. We can do better than that can't we
> ?!
>
> I really can't understand why the aggregator parameter does not work as I
> expected it to.
> Any idea ?
>
> François
>
>
>
> --
> Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Francois MAROT
Thanks for your response Hervé,

I've made a sample plugin here:
https://github.com/fmarot/print-dummy-maven-plugin
When included in the "<build><plugins>" section of a parent pom of a
multimodule Maven project, the behavior is shown: when running 'mvn
validate', "dummy" is printed for for each and every child execution and in
the parent.
As I set aggregator to "true" in my Mojo, I expected it to be executed only
once.

I can provide a sample multimodule if needed.

Regards



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

rfscholte
IIUC the aggregator only works when calling a goal directly, not as part  
of the lifecycle.
That's why release:prepare / release:perform works
I can't think of a plugin that is part of the lifecycle AND which act as  
an aggregator.

thanks,
Robert



On Mon, 08 Jan 2018 14:25:36 +0100, Francois MAROT  
<[hidden email]> wrote:

> Thanks for your response Hervé,
>
> I've made a sample plugin here:
> https://github.com/fmarot/print-dummy-maven-plugin
> When included in the "<build><plugins>" section of a parent pom of a
> multimodule Maven project, the behavior is shown: when running 'mvn
> validate', "dummy" is printed for for each and every child execution and  
> in
> the parent.
> As I set aggregator to "true" in my Mojo, I expected it to be executed  
> only
> once.
>
> I can provide a sample multimodule if needed.
>
> Regards
>
>
>
> --
> Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Francois MAROT
Thanks Robert, that makes sense. At least it explains why aggregator will not
work in my case.
Do you think my case is not so uncommon and I should open a bug, or I
misunderstood "the Maven way" and have to adapt ?

Regards



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

rfscholte
Based on the current requirement as described by Karl Heinz there seems to  
be room for it.
I don't expect this to be part of Maven3, but we have more lifecycle  
related improvements planned for a next major[1].
Just create the issue as an improvement, and let's see what the impact  
will be.

thanks
Robert

[1] https://issues.apache.org/jira/browse/MNG-5665

On Tue, 09 Jan 2018 13:44:48 +0100, Francois MAROT  
<[hidden email]> wrote:

> Thanks Robert, that makes sense. At least it explains why aggregator  
> will not
> work in my case.
> Do you think my case is not so uncommon and I should open a bug, or I
> misunderstood "the Maven way" and have to adapt ?
>
> Regards
>
>
>
> --
> Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Make custom plugin executed only once in multimodule (inherited=false? aggregator?)

Francois MAROT
Thanks Robert, Karl, I created a JIRA MNG-6336 here:
https://issues.apache.org/jira/browse/MNG-6336



--
Sent from: http://maven.40175.n5.nabble.com/Maven-Users-f40176.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]