You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Francois MAROT <fr...@gmail.com> on 2018/01/05 13:32:58 UTC

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

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

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

Posted by Francois MAROT <fr...@gmail.com>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Robert Scholte <rf...@apache.org>.
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  
<fr...@gmail.com> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Francois MAROT <fr...@gmail.com>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Robert Scholte <rf...@apache.org>.
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  
<fr...@gmail.com> 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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Francois MAROT <fr...@gmail.com>.
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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Hervé BOUTEMY <he...@free.fr>.
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: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


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

Posted by Francois MAROT <fr...@gmail.com>.
[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: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org