Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

My parent pom exlicitly declares a dependence on maven-javadoc-plugin 2.9.1 in both

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

and

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

(see Maven plugin version in pom (seemingly) ignored ) and mvn help:effective-pom shows 2.9.1 is being used. However, the build is using 2.10 which is causes build failures (see maven-javadoc-plugin breaks mvn release:perform and http://jira.codehaus.org/browse/MJAVADOC-407 )

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 2.10 instead, causing a build failure.

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

(I'm using Maven 3.2.1)

like image 267
djb Avatar asked Sep 24 '14 19:09

djb


People also ask

What is the difference between plugin and pluginManagement tags?

pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.

What is the difference between Maven plugin and Maven dependency?

A plugin is an extension to Maven, something used to produce your artifact (maven-jar-plugin for an example, is used to, you guess it, make a jar out of your compiled classes and resources). A dependency is a library that is needed by the application you are building, at compile and/or test and/or runtime time.

What are the two types of Maven plugins?

Introduction. In Maven, there are two kinds of plugins, build and reporting: Build plugins are executed during the build and configured in the <build/> element. Reporting plugins are executed during the site generation and configured in the <reporting/> element.


1 Answers

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.

like image 69
dres Avatar answered Oct 29 '22 17:10

dres