Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does google-api-client depend on guava-jdk5?

I have a dependency on Guava in my Maven dependencies:

<dependency>
    <groupId>com.google.guava</groupId>
    <artifactId>guava</artifactId>
    <version>23.3-jre</version>
</dependency>

I also have a dependency to Google API Client in my dependencies:

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.23.0</version>
</dependency>

But for some odd reason, this has the following dependency:

<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava-jdk5</artifactId>
</dependency>

Now my WAR ends up with two Guava JARs:

  • guava-23.3-jre.jar
  • guava-jdk5-17.0.jar

This gives several issues, since the runtime prefers guava-jdk5-17.0.jar while the code is compiled with guava-23.3-jre.jar.

Why does Google API Client have dependency on Guava for JDK5? Wouldn't it make more sense to have two versions, like:

  • google-api-client which depends on regular Guava, preferably version 23.3 (as of current)
  • google-api-client-jdk5 which depends on Guava for JDK5
like image 988
Franz They Avatar asked Nov 05 '17 20:11

Franz They


1 Answers

See https://github.com/google/google-api-java-client/issues/903. The following work-around should be possible:

    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <exclusions>
            <exclusion>
                <groupId>com.google.guava</groupId>
                <artifactId>guava-jdk5</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
like image 101
Franz They Avatar answered Nov 03 '22 02:11

Franz They