Skip to content

Commit

Permalink
Under Gradle, return to having guava automatically pull in the empt…
Browse files Browse the repository at this point in the history
…y `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 #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 #6642

RELNOTES=Removed the section of our Gradle metadata that caused Gradle to report conflicts with `listenablefuture`.
PiperOrigin-RevId: 552447789
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jul 31, 2023
1 parent 347ef4e commit 9ed0fa6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 36 deletions.
48 changes: 28 additions & 20 deletions guava/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -76,11 +83,6 @@
"group": "com.google.collections",
"name": "google-collections",
"version": "${pom.version}"
},
{
"group": "com.google.guava",
"name": "listenablefuture",
"version": "1.0"
}
]
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -141,11 +150,6 @@
"group": "com.google.collections",
"name": "google-collections",
"version": "${pom.version}"
},
{
"group": "com.google.guava",
"name": "listenablefuture",
"version": "1.0"
}
]
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -210,11 +221,6 @@
"group": "com.google.collections",
"name": "google-collections",
"version": "${pom.version}"
},
{
"group": "com.google.guava",
"name": "listenablefuture",
"version": "1.0"
}
]
},
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -275,11 +288,6 @@
"group": "com.google.collections",
"name": "google-collections",
"version": "${pom.version}"
},
{
"group": "com.google.guava",
"name": "listenablefuture",
"version": "1.0"
}
]
}
Expand Down
22 changes: 6 additions & 16 deletions integration-tests/gradle/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ 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(
"guava-$guavaVersionJre.jar",
"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")
Expand All @@ -27,7 +29,6 @@ val expectedCompileClasspathJreVersion =

val extraLegacyDependencies =
setOf(
"listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar",
"google-collections-1.0.jar"
)

Expand Down Expand Up @@ -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 {
Expand All @@ -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") -> {
Expand Down Expand Up @@ -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) }
}
}
}

Expand Down

0 comments on commit 9ed0fa6

Please sign in to comment.