You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Warner Onstine <wa...@gmail.com> on 2013/03/07 01:01:17 UTC

multi-module lifecycle question

Hi all, been working with a multi-module build that has the following
characteristics:
- All sub-modules have the parent pom as their parent
- I have Integration tests setup as their own module
- parent pom has profiles for specific environments setup

In the parent pom I have the a plugin bound to the prepare-package phase
and inherit marked to false (I only want the plugin to run once at the end
of the build, or once before another phase starts). The behavior I am
seeing though is this:
- Run mvn package -D profileName
- it executes my plugin at the top-level first
- Then it proceeds to compile and run the tests on each of the sub-modules
- It never runs my plugin again

What I expected to happen:
- Compile each sub-module
- Run the tests on each sub-module
- See the prepare-package at the root level (because it now hit that phase)
- Run package on each sub-module

I'm not clear as to why the build is doing all the phases within each
module rather than phase-first then module.

Is there an easy/clean way to do this?

The solution I have come up with so far is either
- turn inherit to true and it will run my plugin for each module (bad)
- Move my specific phase stuff into each module that may need it for each
profile (pain in the ass)

Other ideas?

-warner

Re: multi-module lifecycle question

Posted by Barrie Treloar <ba...@gmail.com>.
On 7 March 2013 10:59, Warner Onstine <wa...@gmail.com> wrote:
> The plugin wipes the db clean from test data and preps it for integration
> testing.

Remember that each "module" is a self contained artifact (usually a jar).

So if you are doing integration testing, you probably need to have
build your entire stack before you could run anything.

The usual way is to have a separate integration testing module which
depends on the appropriate artifacts, then configure your plugin there
at the appropriate phase (say initialize).
Then you dont need anything in your parent at all.

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


Re: multi-module lifecycle question

Posted by Warner Onstine <wa...@gmail.com>.
The plugin wipes the db clean from test data and preps it for integration
testing.

-warner

On Wednesday, March 6, 2013, Barrie Treloar wrote:

> On 7 March 2013 10:31, Warner Onstine <warnero@gmail.com <javascript:;>>
> wrote:
> > Hi all, been working with a multi-module build that has the following
> > characteristics:
> > - All sub-modules have the parent pom as their parent
> > - I have Integration tests setup as their own module
> > - parent pom has profiles for specific environments setup
> >
> > In the parent pom I have the a plugin bound to the prepare-package phase
> > and inherit marked to false (I only want the plugin to run once at the
> end
> > of the build, or once before another phase starts). The behavior I am
> > seeing though is this:
> > - Run mvn package -D profileName
> > - it executes my plugin at the top-level first
> > - Then it proceeds to compile and run the tests on each of the
> sub-modules
> > - It never runs my plugin again
> >
> > What I expected to happen:
> > - Compile each sub-module
> > - Run the tests on each sub-module
> > - See the prepare-package at the root level (because it now hit that
> phase)
> > - Run package on each sub-module
>
> The Maven reactor runs the complete lifecycle
> (
> http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
> )
> in the order specified by the build plan.
> In your case it would be Parent, Module 1, Module 2, ..., Module N
>
> It does not run each step of the lifecycle against each module before
> progressing to the next step in the lifecycle.
> i.e it does not do:
> * Compile
> ** Parent
> ** Module 1
> ** ...
> ** Module N
> ...
> * Package
> ** Parent
> ** Module 1
> ...
> ** Module N
>
> >
> > I'm not clear as to why the build is doing all the phases within each
> > module rather than phase-first then module.
> >
> > Is there an easy/clean way to do this?
> >
> > The solution I have come up with so far is either
> > - turn inherit to true and it will run my plugin for each module (bad)
> > - Move my specific phase stuff into each module that may need it for each
> > profile (pain in the ass)
> >
> > Other ideas?
>
> Without knowing what your plugin does, and why you are attempting to
> do it this way, it is difficult to provide any more concrete advice.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org <javascript:;>
> For additional commands, e-mail: users-help@maven.apache.org<javascript:;>
>
>

Re: multi-module lifecycle question

Posted by Barrie Treloar <ba...@gmail.com>.
On 7 March 2013 10:31, Warner Onstine <wa...@gmail.com> wrote:
> Hi all, been working with a multi-module build that has the following
> characteristics:
> - All sub-modules have the parent pom as their parent
> - I have Integration tests setup as their own module
> - parent pom has profiles for specific environments setup
>
> In the parent pom I have the a plugin bound to the prepare-package phase
> and inherit marked to false (I only want the plugin to run once at the end
> of the build, or once before another phase starts). The behavior I am
> seeing though is this:
> - Run mvn package -D profileName
> - it executes my plugin at the top-level first
> - Then it proceeds to compile and run the tests on each of the sub-modules
> - It never runs my plugin again
>
> What I expected to happen:
> - Compile each sub-module
> - Run the tests on each sub-module
> - See the prepare-package at the root level (because it now hit that phase)
> - Run package on each sub-module

The Maven reactor runs the complete lifecycle
(http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html)
in the order specified by the build plan.
In your case it would be Parent, Module 1, Module 2, ..., Module N

It does not run each step of the lifecycle against each module before
progressing to the next step in the lifecycle.
i.e it does not do:
* Compile
** Parent
** Module 1
** ...
** Module N
...
* Package
** Parent
** Module 1
...
** Module N

>
> I'm not clear as to why the build is doing all the phases within each
> module rather than phase-first then module.
>
> Is there an easy/clean way to do this?
>
> The solution I have come up with so far is either
> - turn inherit to true and it will run my plugin for each module (bad)
> - Move my specific phase stuff into each module that may need it for each
> profile (pain in the ass)
>
> Other ideas?

Without knowing what your plugin does, and why you are attempting to
do it this way, it is difficult to provide any more concrete advice.

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