755
755

Reputation: 3091

Change Maven dependencies of a Maven dependency in Eclipse

I have a Maven dependency that depends on google-collections 1.0.

My main project uses guava 14.0, which is google-collections renamed.

When I export my project as a jar, the google-collections dependency overrides the guava 14.0, causing my project to error whenever I want to access a method that was implemented later than version 1.0

How can I make the Maven dependency use guava 14.0 instead of google-collections?

Upvotes: 0

Views: 67

Answers (1)

messivanio
messivanio

Reputation: 2311

You can use maven dependency exclusions.

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>sample.ProjectA</groupId>
      <artifactId>Project-A</artifactId>
      <version>1.0</version>
      <scope>compile</scope>
      <exclusions>
        <exclusion>  <!-- declare the exclusion here -->
          <groupId>sample.ProjectB</groupId>
          <artifactId>Project-B</artifactId>
        </exclusion>
      </exclusions> 
    </dependency>
  </dependencies>
</project>

Upvotes: 3

Related Questions