Please understand that your aggregating project (what you call "top level
pom") runs first (thus your plugin binding is executed), then the modules
(what you call "child poms") are built.
So everything is as expected, but not what you want. :-)

This "problem" is described in the FAQ for the maven-assembly-plugin [1].
Have a look there how it has been solved.

/Anders

[1]
http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries

On Wed, Feb 2, 2011 at 06:13, E S <[email protected]> wrote:

> I have a maven project consisting of a top level pom and several child poms
> under it. Each child project has a set of units tests that are output by
> surefire. I have written a custom plugin that will combine the results of
> all the sub-projects unit tests into a single file to be fed into our build
> server. I would like for this plugin to be run during the package phase of
> the top level build. The idea is that all the projects run their tests and
> output their surefire reports during the test phase and then after that is
> done, my plugin consolidates them during the package phase. In order to do
> this, I have added the a reference to plugin to the top level pom file's
> build section like this:
>
> <build>
>   <finalName>whatever</finalName>
>   <plugins>
>      <plugin>
>         <groupId>my.plugin.group</groupId>
>         <artifactId>consolidator</artifactId>
>         <version>1.0-SNAPSHOT</version>
>         <inherited>false</inherited>
>         <executions>
>            <execution>
>               <id>execution1</id>
>               <phase>package</phase>
>               <goals>
>                  <goal>junit</goal>
>               </goals>
>               <configuration>
>                  <rootDir>${basedir}</rootDir>
>                  <outFile>${basedir}/testresults.xml</outFile>
>               </configuration>
>            </execution>
>         </executions>
>      </plugin>
>   </plugins>
> </build>
>
> The problem is that when I run the build, the consolidator plugin runs way
> before the unit tests have gotten a chance to run. It's almost the first
> thing that gets run during the build. I can't figure out why this would
> happen. I have clearly designated it to run during the package phase. In
> fact, when I use the plugin directly inside one of the sub-projects (just
> to
> see if it would work) it runs at the correct time. What is different about
> the top level pom?
>

Reply via email to