views:

190

answers:

2

Hi,

I just found something that sounds weird with Maven plugin management.

While working on the site generation I wanted to use a specific version of the maven site plugin in order to have a specific functionnalty working. Let's say I want to use version 2.0.1 of this plugin.

If I use the reporting section of my POM in order to generate my project's site with the command:

mvn site

this works well. I mean the plugin version used is 2.0.1 as I wanted. Here is an extract from my POM configuring the site plugin:

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>2.0.1</version>
        </plugin>
    </plugins>
</reporting>

Now if I want my site to be generated during a specific phase of the build life cycle, let's say prepare-package (and goal stage), I add the following section in the section:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>

        <executions>
            <execution>
                <phase>prepare-package</phase>
                <goals>
                    <goal>stage</goal>
                </goals>
            </execution>
        </executions>
     </plugin>
</plugins>

And here I am stuck with the maven site plugin version coming from the Super POM, ie. 2.0-beta-7. Even if I try to add the configuration specifying I really want to use version 2.0.1 it still uses 2.0-beta-7. I also tried to add the version in the section because the config that is used in the reporting section is supposed to be applied to the build section also. But this does not work neither.

Maybe I missed something, and correct me if I am wrong but this looks like a bug. Is there a need on the Maven side to fix plugin's version to be used during the build process?

Thanks!

+1  A: 

I think you need to use the "pluginManagement" section to set the global version number of the plugin.

krosenvold
+4  A: 

If you define a pluginManagement section in the pom, you can declare the versions used for any plugins, this will override the versions inherited from the super POM

For example:

<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>maven-site-plugin</artifactId>
      <version>2.0.1</version>
    </plugin>       
  </plugins>
</pluginManagement>

You can refer to the documentation for some background on configuring pluginManagement.

Rich Seller
Thanks a lot for this quick response.This overrides the default value coming from the Super Pom.
reef