How to force the version of a maven plugin?

6

I have a maven project such that, at the time of running build , a plugin A runs. This plugin A depends on a B plugin that is pulled, which in turn depends on a C plugin.

It turns out that this C plugin is in an X version that has an annoying bug, and I want to force maven to use a Y version.

Also, I do not use the C plugin directly. I also do not even know which plugin B uses it. But if I delete it from the repository and try to compile offline, maven complains.

What can I do to force maven to use the desired version?

    
asked by anonymous 19.12.2013 / 18:46

2 answers

2

You can try to use the pluginManagement section to set the desired version of the plugin:

<pluginManagement>
  <plugins>
    <plugin>
      <artifactId>C</artifactId>
      <version>Y</version>
    </plugin>       
  </plugins>
</pluginManagement>

Take a look at documentation for more information.

    
19.12.2013 / 18:50
3

There are two options:

  • Add the desired version as a direct dependency of your project, so it will have priority in resolving dependencies.

  • Delete the incorrect dependency. Example:

  •   <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <dependencies>
          <dependency>
            <groupId>net.sf.jtidy</groupId>
            <artifactId>jtidy</artifactId>
            <version>r938</version>
          </dependency>
          <dependency>
            <groupId>org.apache.maven.plugin-tools</groupId>
            <artifactId>maven-plugin-tools-api</artifactId>
            <version>2.5.1</version>
            <exclusions>
              <exclusion>
                <groupId>jetty</groupId>
                <artifactId>jetty</artifactId>
              </exclusion>
            </exclusions>
          </dependency>
        </dependencies>
      </plugin>
    
        
    19.12.2013 / 18:56