Search code examples
maven-3maven-pluginversioningmaven-dependency-pluginmaven-javadoc-plugin

Why does Maven use the wrong plugin despite explicit plugin and pluginManagement version?


My parent POM explicitly declares a dependency on maven-javadoc-plugin 2.9.1 (MJP) in both

    <pluginManagement>
       <plugins>
         <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
         </plugin>
            ...
        <reporting>
          <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-javadoc-plugin</artifactId>
             <version>2.9.1</version>
             ...

and mvn help:effective-pom shows 2.9.1 is being used. However, the build is using 2.10 which is causes build failures. This is like maven-javadoc-plugin breaks mvn release:perform. mvn help:describe -DgroupId=org.apache.maven.plugins -DartifactId=maven-javadoc-plugin shows

Name: Apache Maven Javadoc Plugin
Description: The Apache Maven Javadoc Plugin is a plugin that uses the javadoc tool for generating javadocs for the specified project.
Group Id: org.apache.maven.plugins
Artifact Id: maven-javadoc-plugin
Version: 2.10
Goal Prefix: javadoc

Meanwhile, mvn dependency:resolve-plugins shows [INFO] Plugin Resolved: maven-javadoc-plugin-2.9.1.jar. Yet when I run the build, mvn uses MJP version 2.10 instead, causing a build failure. I'm using Maven version 3.2.1.

How can I force maven to use 2.9.1 and not the broken 2.10?


Solution

  • Be sure that you are looking at the right dependency. We are seeing that 2.9.1 as specified is being used for site reports but 2.10 is being used by the build. I believe you should specify it in your

    <build><plugins>

    section as well.

    We just verified that we were suffering the same problem. We had the plugin version in the reporting plugins section but not build plugins. Once we added it to the build plugins section, the issue was resolved. The reason it needed to be in build plugins was because it was being used in the prepare deploy phase to build a javadoc jar. This happens separately from generating javadoc for the site reports.