You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by fa...@mpsa.com on 2005/10/18 14:35:23 UTC

[m2] Running a goal only once in a multiproject context




Hi,

I have defined a Mojo that does some work (create some necessary folders,
init some dynamic values, ...) before running an install over my
multi-module project. When I run "m2 myGroupId:myArtifactId:myGoal install"
on my master project, my goal gets executed for each submodule while I need
it to be executed only once at the very beginning of the build.
Is there a way to tell the Mojo that it must be executed only once? I
looked at the "plugin.xml" file placed in the META-INF of the plugin, but I
can't figure out what the different parameters are for
(requiresDirectInvocation, inheritedByDefault, executionStrategy, ...).

Btw, is there also a way to define an alias so that I don't need to write
"m2 myGroupId:myArtifactId:myGoal", but only "m2 shortId:myGoal" for
instance ?

Thanks for your help!

Best Regards / Cordialement,
Fabrice BELLINGARD
DINQ/DSIN/INSI/EATE/IDVS/AIDV
(+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com


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


Re: [m2] Running a goal only once in a multiproject context

Posted by fa...@mpsa.com.



Thanks for your answer John! :o)

Best Regards / Cordialement,
Fabrice BELLINGARD
DINQ/DSIN/INSI/EATE/IDVS/AIDV
(+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com


                                                                           
             John Casey                                                    
             <jdcasey@commonj                                              
             ava.org>                                                 Pour 
                                       Maven Users List                    
             18/10/2005 17:04          <us...@maven.apache.org>            
                                                                        cc 
                                                                           
                 Veuillez                                            Objet 
                répondre à             Re: [m2] Running a goal only once   
             Maven Users List          in a multiproject context           
             <users@maven.apa                                              
                 che.org>                                                  
                                                                           
                                                                           
                                                                           
                                                                           




-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try adding the class-level annotation:

@aggregator

to your mojo. This will tell the mojo to only execute at the top level.
If you need access to the List of project instances in the current
build, use the following:

/**
~ * @parameter default-value="${reactorProjects}"
~ * @required
~ * @readonly
~ */
private java.util.List reactorProjects;

Also, if you want it to execute before anything else in the build, you
can bind it to the 'initialize' phase using:

<phase>initialize</phase>

within the execution specification for the plugin. NOTE: you'll also
have to enumerate the goals you want to run in a
<goals><goal>myMojo</goal></goals> section, also within the execution
specification.


To answer your second question, try adding the following to your
plugin's POM:

<build>
...
~  <plugins>
~    <plugin>
~      <artifactId>maven-plugin-plugin</artifactId>
~      <configuration>
~        <prefix>myPluginPrefix</prefix>
~      </configuration>
~    </plugin>
~  </plugins>
...
</build>

When you re-install/deploy the plugin, this *should* allow you to specify:

m2 myPluginPrefix:myMojo

rather than referring to it by groupId:artifactId[:version]:goal.

Cheers,

john

fabrice.belingard@mpsa.com wrote:
|
|
|
| Hi,
|
| I have defined a Mojo that does some work (create some necessary folders,
| init some dynamic values, ...) before running an install over my
| multi-module project. When I run "m2 myGroupId:myArtifactId:myGoal
install"
| on my master project, my goal gets executed for each submodule while I
need
| it to be executed only once at the very beginning of the build.
| Is there a way to tell the Mojo that it must be executed only once? I
| looked at the "plugin.xml" file placed in the META-INF of the plugin,
but I
| can't figure out what the different parameters are for
| (requiresDirectInvocation, inheritedByDefault, executionStrategy, ...).
|
| Btw, is there also a way to define an alias so that I don't need to write
| "m2 myGroupId:myArtifactId:myGoal", but only "m2 shortId:myGoal" for
| instance ?
|
| Thanks for your help!
|
| Best Regards / Cordialement,
| Fabrice BELLINGARD
| DINQ/DSIN/INSI/EATE/IDVS/AIDV
| (+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
| For additional commands, e-mail: users-help@maven.apache.org
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFDVQ7sK3h2CZwO/4URAjfcAKCcsMYU71YCHoMoiDbmjvDdqEaCzgCeJYSY
1reEdoqWeJ3WtQA9hRAVMS4=
=zV4b
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
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: [m2] Running a goal only once in a multiproject context

Posted by John Casey <jd...@commonjava.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try adding the class-level annotation:

@aggregator

to your mojo. This will tell the mojo to only execute at the top level.
If you need access to the List of project instances in the current
build, use the following:

/**
~ * @parameter default-value="${reactorProjects}"
~ * @required
~ * @readonly
~ */
private java.util.List reactorProjects;

Also, if you want it to execute before anything else in the build, you
can bind it to the 'initialize' phase using:

<phase>initialize</phase>

within the execution specification for the plugin. NOTE: you'll also
have to enumerate the goals you want to run in a
<goals><goal>myMojo</goal></goals> section, also within the execution
specification.


To answer your second question, try adding the following to your
plugin's POM:

<build>
...
~  <plugins>
~    <plugin>
~      <artifactId>maven-plugin-plugin</artifactId>
~      <configuration>
~        <prefix>myPluginPrefix</prefix>
~      </configuration>
~    </plugin>
~  </plugins>
...
</build>

When you re-install/deploy the plugin, this *should* allow you to specify:

m2 myPluginPrefix:myMojo

rather than referring to it by groupId:artifactId[:version]:goal.

Cheers,

john

fabrice.belingard@mpsa.com wrote:
|
|
|
| Hi,
|
| I have defined a Mojo that does some work (create some necessary folders,
| init some dynamic values, ...) before running an install over my
| multi-module project. When I run "m2 myGroupId:myArtifactId:myGoal
install"
| on my master project, my goal gets executed for each submodule while I
need
| it to be executed only once at the very beginning of the build.
| Is there a way to tell the Mojo that it must be executed only once? I
| looked at the "plugin.xml" file placed in the META-INF of the plugin,
but I
| can't figure out what the different parameters are for
| (requiresDirectInvocation, inheritedByDefault, executionStrategy, ...).
|
| Btw, is there also a way to define an alias so that I don't need to write
| "m2 myGroupId:myArtifactId:myGoal", but only "m2 shortId:myGoal" for
| instance ?
|
| Thanks for your help!
|
| Best Regards / Cordialement,
| Fabrice BELLINGARD
| DINQ/DSIN/INSI/EATE/IDVS/AIDV
| (+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
|
|
| ---------------------------------------------------------------------
| To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
| For additional commands, e-mail: users-help@maven.apache.org
|
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFDVQ7sK3h2CZwO/4URAjfcAKCcsMYU71YCHoMoiDbmjvDdqEaCzgCeJYSY
1reEdoqWeJ3WtQA9hRAVMS4=
=zV4b
-----END PGP SIGNATURE-----

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


Re: [m2] Running a goal only once in a multiproject context

Posted by fa...@mpsa.com.



Correct and correct!

For "settings.xml", the full syntax is:
      <pluginGroups>
            <pluginGroup>com.mycompany.plugins</pluginGroup>
      </pluginGroups>

Thanks Milos!

Best Regards / Cordialement,
Fabrice BELLINGARD
DINQ/DSIN/INSI/EATE/IDVS/AIDV
(+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com


                                                                           
             Milos Kleint                                                  
             <Milos.Kleint@Su                                              
             n.COM>                                                   Pour 
                                       Maven Users List                    
             18/10/2005 14:41          <us...@maven.apache.org>            
                                                                        cc 
                                                                           
                 Veuillez                                            Objet 
                répondre à             Re: [m2] Running a goal only once   
             Maven Users List          in a multiproject context           
             <users@maven.apa                                              
                 che.org>                                                  
                                                                           
                                                                           
                                                                           
                                                                           




i think adding @aggregator to the mojo's class javadoc does the trick..

there needs to be the plugin's group id added to the settings.xml file
.. the element is called something like <pluginGroups>

milos

fabrice.belingard@mpsa.com wrote:
>
>
> Hi,
>
> I have defined a Mojo that does some work (create some necessary folders,
> init some dynamic values, ...) before running an install over my
> multi-module project. When I run "m2 myGroupId:myArtifactId:myGoal
install"
> on my master project, my goal gets executed for each submodule while I
need
> it to be executed only once at the very beginning of the build.
> Is there a way to tell the Mojo that it must be executed only once? I
> looked at the "plugin.xml" file placed in the META-INF of the plugin, but
I
> can't figure out what the different parameters are for
> (requiresDirectInvocation, inheritedByDefault, executionStrategy, ...).
>
> Btw, is there also a way to define an alias so that I don't need to write
> "m2 myGroupId:myArtifactId:myGoal", but only "m2 shortId:myGoal" for
> instance ?
>
> Thanks for your help!
>
> Best Regards / Cordialement,
> Fabrice BELLINGARD
> DINQ/DSIN/INSI/EATE/IDVS/AIDV
> (+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
>
>
> ---------------------------------------------------------------------
> 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




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


Re: [m2] Running a goal only once in a multiproject context

Posted by Milos Kleint <Mi...@Sun.COM>.
i think adding @aggregator to the mojo's class javadoc does the trick..

there needs to be the plugin's group id added to the settings.xml file 
.. the element is called something like <pluginGroups>

milos

fabrice.belingard@mpsa.com wrote:
>
>
> Hi,
>
> I have defined a Mojo that does some work (create some necessary folders,
> init some dynamic values, ...) before running an install over my
> multi-module project. When I run "m2 myGroupId:myArtifactId:myGoal install"
> on my master project, my goal gets executed for each submodule while I need
> it to be executed only once at the very beginning of the build.
> Is there a way to tell the Mojo that it must be executed only once? I
> looked at the "plugin.xml" file placed in the META-INF of the plugin, but I
> can't figure out what the different parameters are for
> (requiresDirectInvocation, inheritedByDefault, executionStrategy, ...).
>
> Btw, is there also a way to define an alias so that I don't need to write
> "m2 myGroupId:myArtifactId:myGoal", but only "m2 shortId:myGoal" for
> instance ?
>
> Thanks for your help!
>
> Best Regards / Cordialement,
> Fabrice BELLINGARD
> DINQ/DSIN/INSI/EATE/IDVS/AIDV
> (+33) (01 61) 45 15 91  -  fabrice.belingard@mpsa.com
>
>
> ---------------------------------------------------------------------
> 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