v32.1.0
版本发布时间: 2023-06-30 04:24:12
google/guava最新发布版本:v33.3.1(2024-09-24 04:55:13)
Maven
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.0-jre</version>
<!-- or, for Android: -->
<version>32.1.0-android</version>
</dependency>
Jar files
Guava requires one runtime dependency, which you can download here:
Javadoc
JDiff
Changelog
Gradle Module Metadata
The Gradle team has contributed a metadata file for Guava. If you use Gradle 6 or higher, you will see better handling of two kinds of dependency conflicts, plus another small feature related to our dependencies:
Selecting the appropriate flavor
When Gradle automatically selects the newest version of Guava in your dependency graph, it will now also select the appropriate flavor (-android
or -jre
) based on whether you project targets Android or not. For example, if you depend on 32.1.0-android and 30.0-jre, Gradle will select 32.1.0-jre. This is the version most likely to be compatible with all your dependencies.
In the unusual event that you need to override Gradle's choice of flavor, you can do so as follows:
dependencies.constraints {
implementation("com.google.guava:guava") {
attributes {
attribute(
TargetJvmEnvironment.TARGET_JVM_ENVIRONMENT_ATTRIBUTE,
objects.named(TargetJvmEnvironment, TargetJvmEnvironment.ANDROID))
}
}
}
// If the above leads to a conflict error because there are additional transitive dependencies to Guava, then use:
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:guava") {
select(candidates.find { it.variantName.contains("android") })
}
}
Reporting dependencies that overlap with Guava
If your dependency graph contains the very old google-collections
or the hacky listenablefuture
, Gradle will now report that those libraries contain duplicates of Guava classes. When this happens, you'll need to tell Gradle to select Guava:
configurations.all {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:0")
}
// and/or
resolutionStrategy.capabilitiesResolution.withCapability("com.google.guava:listenablefuture") {
select("com.google.guava:guava:0")
}
}
Omitting annotations at runtime
One dependency of Guava that is not needed at runtime (j2objc-annotations
) is now omitted from the runtime classpath. (We may omit others in the future. See #6606.)
Other changes
-
collect
: Tweaked more nullness annotations. (501a01631f742bbcb73cf46ae409abf567903944, 5c2359087acc36c86ed42f1875ce69b7be231868) -
hash
: Enhancedcrc32c()
to use Java's hardware-accelerated implementation where available. (65c7f10ff0) -
util.concurrent
: AddedDuration
-baseddefault
methods toListeningExecutorService
. (e7714b0b8b) - Began updating Javadoc to focus less on APIs that have been superseded by additions to the JDK. We're also looking to add more documentation that directs users to JDK equivalents for our APIs. Further PRs welcome! (c9efc479950e40be4a11daa707dcf9258745cc2e, 01dcc2e6104e9bd0392cb19029edf2c581425b67)
- Fixed some problems with using Guava from a Java Agent. (But we don't test that configuration, and we don't know how well we'll be able to keep it working.) (e42d4e863b, de62703987)
- Fixed
BootstrapMethodError
when usingCacheBuilder
from a custom system class loader. (As with the previous item, we're not sure how well we'll be able to keep this use case working.) (a667c38772) - Suppressed a harmless
unusable-by-js
warning seen by users ofguava-gwt
.