How to force the version of a Maven plugin?

Asked

Viewed 173 times

6

I have such a Maven project, that at the time of running the build, an A plugin runs. This A plugin 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 don’t use the C plugin directly. I don’t even know which B plugin 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?

  • The esteemed companion who voted against my question, would you please explain what you think is wrong with her?

2 answers

3

There are two options:

  1. add the desired version as a direct dependency on your project, so it will have priority in resolving dependencies.

  2. 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>

2


You can try using the section pluginManagement to fix the desired version of the plugin:

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

Take a look at documentation (in English) for more information.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.