From 9ed0fa65ab0ecdf2f10d506e7dffeb3595953777 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 31 Jul 2023 05:07:56 -0700 Subject: [PATCH] Under Gradle, return to having `guava` automatically pull in the empty `listenablefuture-9999....jar` instead of making Gradle report a conflict that users need to [resolve](https://github.com/google/guava/releases/tag/v32.1.0#user-content-overlap). See discussion in https://github.com/google/guava/issues/6642: The Gradle module metadata does multiple things, most of which bring clear benefits but one of which (the `listenablefuture` part) may bring more costs than benefits at this point. (Accordingly, this CL rolls back one tiny fragment of the larger cl/544108700.) Fixes https://github.com/google/guava/issues/6642 RELNOTES=Removed the section of our Gradle metadata that caused Gradle to report conflicts with `listenablefuture`. PiperOrigin-RevId: 552447789 --- guava/module.json | 48 +++++++++++++---------- integration-tests/gradle/build.gradle.kts | 22 +++-------- 2 files changed, 34 insertions(+), 36 deletions(-) diff --git a/guava/module.json b/guava/module.json index 42bb4d33413b..9d78db10faee 100644 --- a/guava/module.json +++ b/guava/module.json @@ -43,6 +43,13 @@ "requires": "1.0.1" } }, + { + "group": "com.google.guava", + "module": "listenablefuture", + "version": { + "requires": "9999.0-empty-to-avoid-conflict-with-guava" + } + }, { "group": "com.google.code.findbugs", "module": "jsr305" @@ -76,11 +83,6 @@ "group": "com.google.collections", "name": "google-collections", "version": "${pom.version}" - }, - { - "group": "com.google.guava", - "name": "listenablefuture", - "version": "1.0" } ] }, @@ -112,6 +114,13 @@ "requires": "1.0.1" } }, + { + "group": "com.google.guava", + "module": "listenablefuture", + "version": { + "requires": "9999.0-empty-to-avoid-conflict-with-guava" + } + }, { "group": "com.google.code.findbugs", "module": "jsr305" @@ -141,11 +150,6 @@ "group": "com.google.collections", "name": "google-collections", "version": "${pom.version}" - }, - { - "group": "com.google.guava", - "name": "listenablefuture", - "version": "1.0" } ] }, @@ -177,6 +181,13 @@ "requires": "1.0.1" } }, + { + "group": "com.google.guava", + "module": "listenablefuture", + "version": { + "requires": "9999.0-empty-to-avoid-conflict-with-guava" + } + }, { "group": "com.google.code.findbugs", "module": "jsr305" @@ -210,11 +221,6 @@ "group": "com.google.collections", "name": "google-collections", "version": "${pom.version}" - }, - { - "group": "com.google.guava", - "name": "listenablefuture", - "version": "1.0" } ] }, @@ -246,6 +252,13 @@ "requires": "1.0.1" } }, + { + "group": "com.google.guava", + "module": "listenablefuture", + "version": { + "requires": "9999.0-empty-to-avoid-conflict-with-guava" + } + }, { "group": "com.google.code.findbugs", "module": "jsr305" @@ -275,11 +288,6 @@ "group": "com.google.collections", "name": "google-collections", "version": "${pom.version}" - }, - { - "group": "com.google.guava", - "name": "listenablefuture", - "version": "1.0" } ] } diff --git a/integration-tests/gradle/build.gradle.kts b/integration-tests/gradle/build.gradle.kts index c66ff7c12d67..79db509a419e 100644 --- a/integration-tests/gradle/build.gradle.kts +++ b/integration-tests/gradle/build.gradle.kts @@ -10,7 +10,8 @@ val expectedReducedRuntimeClasspathAndroidVersion = "failureaccess-1.0.1.jar", "jsr305-3.0.2.jar", "checker-qual-3.33.0.jar", - "error_prone_annotations-2.18.0.jar" + "error_prone_annotations-2.18.0.jar", + "listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" ) val expectedReducedRuntimeClasspathJreVersion = setOf( @@ -18,7 +19,8 @@ val expectedReducedRuntimeClasspathJreVersion = "failureaccess-1.0.1.jar", "jsr305-3.0.2.jar", "checker-qual-3.33.0.jar", - "error_prone_annotations-2.18.0.jar" + "error_prone_annotations-2.18.0.jar", + "listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" ) val expectedCompileClasspathAndroidVersion = expectedReducedRuntimeClasspathAndroidVersion + setOf("j2objc-annotations-2.8.jar") @@ -27,7 +29,6 @@ val expectedCompileClasspathJreVersion = val extraLegacyDependencies = setOf( - "listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", "google-collections-1.0.jar" ) @@ -60,7 +61,7 @@ subprojects { // - variant decision is made based on version suffix (android/jre) and not on the actual // environment // - runtime classpath equals the compile classpath - // - dependency conflict with Google Collections is not detected and '9999.0' hack is present + // - dependency conflict with Google Collections is not detected if (name.startsWith("android")) { expectedCompileClasspathAndroidVersion + extraLegacyDependencies } else { @@ -70,7 +71,7 @@ subprojects { // with Gradle Module Metadata // - variant is chosen based on the actual environment, independent of version suffix // - reduced runtime classpath is used (w/o annotation libraries) - // - capability conflicts are detected between Google Collections and listenablefuture + // - capability conflicts are detected with Google Collections if (name.contains("Android") && !name.contains("JreConstraint")) { when { name.contains("RuntimeClasspath") -> { @@ -127,17 +128,6 @@ subprojects { } ?.apply { select(this) } } - withCapability("com.google.guava:listenablefuture") { - candidates - .find { - val idField = - it.javaClass.getDeclaredMethod( - "getId" - ) // reflective access to make this compile with Gradle 5 - (idField.invoke(it) as ModuleComponentIdentifier).module == "guava" - } - ?.apply { select(this) } - } } }