question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Libraries BOM for Guava's -jre flavor (Java 8+)

See original GitHub issue

Shall we create the Libraries BOM with Guava’s -jre flavor?

As of now, the Libraries BOM uses Guava’s -android flavor. This flavor of Guava does not have methods for Java 8+, such as CacheBuilder.expireAfterWrite(java.time.Duration). (Duration class was introduced in Java 8.) If a project uses the Libraries BOM and depends on a library that touches the Java 8+ methods (for example com.google.cloud.bigdataoss:gcsio), the JVM throws NoSuchMethodError:

java.lang.NoSuchMethodError: com.google.common.cache.CacheBuilder.expireAfterWrite(Ljava/time/Duration;)Lcom/google/common/cache/CacheBuilder;
	at com.google.cloud.hadoop.gcsio.GoogleCloudStorageImpl.<init>(GoogleCloudStorageImpl.java:149)

Therefore, Java 8 users in such situations need to override the version of Guava. The step is documented in https://github.com/GoogleCloudPlatform/cloud-opensource-java/wiki/The-Google-Cloud-Platform-Libraries-BOM#guava-versions--jre-or--android . As noted there we cannot override Gradle’s enforcedPlatform keyword, which controls transitive dependency versions. (platform works but this does not control transitive dependencies) Maven users can override transitive dependencies by adding guava entry in the dependencyManagement section.

Given that Java 8 users are majority right now (Java 7 users are few percent in GCP), shall we target for Java 8 users as the main audience?

This request is from @kileys (Dataflow team). The options listed below are prepared by suztomo.

Option 1: change main target audience to Java 8 users

  • The Libraries BOM includes Guava’s -jre flavor that supports Java 8 operations
  • Java 7 users can override the guava version as in the wiki page.

Option 2: two flavors of the Libraries BOM

  • We publish 2 flavors of the Libraries BOM for both Java 8+ and Java 7.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
suztomocommented, Dec 16, 2020

@kileys We’re going to keep the libraries BOM’s Guava as it is until we stop supporting Java 7. When Beam publishes its Beam GCP BOM for Beam users early next year, add the override to choose Beam’s Guava flavor.

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>25.1-jre</version>  <!-- "-jre" for Java 8 or higher -->
      </dependency>
      <dependency>
        <groupId>com.google.cloud</groupId>
        <artifactId>libraries-bom</artifactId>
        <version>16.2.0</version> <!-- the version the Beam release was built with -->
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>

This enables Beam users to select appropriate Guava version (rather than them relying on the Libraries BOM).

0reactions
elharocommented, Jul 22, 2021

Will LTS work moot this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Cloud Client Libraries | Java
Since the release of version 21.0.0, the Libraries BOM includes Guava's -jre flavor (which supports Java 8+). The section below is not applicable...
Read more >
vault/guava: Google core libraries for Java
It is widely used on most Java projects within Google, and widely used by many other companies as well. Guava comes in two...
Read more >
google / guava Download
Guava: Google Core Libraries for Java ; The JRE flavor requires JDK 1.8 or higher. If you need support for Android, use the...
Read more >
com.google.cloud : gcp-lts-bom : 1.0.6 - Maven Central Repository ...
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ...
Read more >
guava: Google core libraries for Java
Google core libraries for Java. ... guava-bom ... Guava provides two different "flavors": one for use on a (Java 8+) JRE and one...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found