commit | 71a16d5a7496857a1faf51f9b4098d1f26fe6cd6 | [log] [tgz] |
---|---|---|
author | cpovirk <cpovirk@google.com> | Mon Jul 31 11:52:58 2023 -0700 |
committer | Google Java Core Libraries <java-core-libraries-team+copybara@google.com> | Mon Jul 31 11:55:22 2023 -0700 |
tree | f87ac568f062a39591f52b20b4b1be491e91237f | |
parent | 9ed0fa65ab0ecdf2f10d506e7dffeb3595953777 [diff] |
Declare versions of test-only dependencies inline instead of in our parent pom. Fixes https://github.com/google/guava/issues/6654, I hope? If `guava` and its parent pom don't refer to `mockito-core`, then `guava` should no longer affect which version of `mockito-core` is selected by Gradle. (Really, it "shouldn't" even now, but there's a mismatch between Maven's model and Gradle's that causes it to do so.) I had initially attempted (in cl/552479838) to declare versions of _all_ our dependencies inline, but that [didn't work](https://github.com/google/guava/issues/6657#issuecomment-1658713156): We [really need `dependencyManagement` for Gradle purposes, at least until we specify versions for Gradle explicitly](https://github.com/google/guava/issues/6654#issuecomment-1656580773). It would be nice if we could still declare our dependency versions only once, now by using `properties`. (In fact, my attempt to use `properties` made me notice that our version of the Error Prone _plugin_ is older than our version of the Error Prone _annotations_.) However, if we were to make that change, then we'd lose the ability to update dependencies with `versions-maven-plugin` (`update-properties` + `use-latest-releases`), I assume because the properties are declared in one `pom.xml` and used in another. (It's possible that Dependabot is better about this, but we've had trouble getting it to work with our unusual 2-flavor, Google-repo-source-of-truth setup.) I notice that we have this problem even today with `truth.version`.... Tested: ``` $ mvn dependency:tree -Dverbose -X -U &> /tmp/pre # made changes $ mvn dependency:tree -Dverbose -X -U &> /tmp/post $ strip() { cat "$@" | grep -v -e 'Dependency collection stats' -e 'Downloading from' -e 'Progress' -e 'Using connector' -e 'Using transporter' -e 'Using mirror' -e maven-dependency-plugin -e SUCCESS -e 'Total time' -e 'Finished at' | sed -e 's/ (.*managed from.*)//'; }; vimdiff <(strip /tmp/pre) <(strip /tmp/post) ``` RELNOTES=Changed our Maven project to avoid [affecting which version of Mockito our Gradle users see](https://github.com/google/guava/issues/6654). PiperOrigin-RevId: 552549819
Guava is a set of core Java libraries from Google that includes new collection types (such as multimap and multiset), immutable collections, a graph library, and utilities for concurrency, I/O, hashing, primitives, strings, and more! It is widely used on most Java projects within Google, and widely used by many other companies as well.
Guava comes in two flavors:
android
directory.Guava's Maven group ID is com.google.guava
, and its artifact ID is guava
. Guava provides two different “flavors”: one for use on a (Java 8+) JRE and one for use on Android or by any library that wants to be compatible with Android. These flavors are specified in the Maven version field as either 32.1.1-jre
or 32.1.1-android
. For more about depending on Guava, see using Guava in your build.
To add a dependency on Guava using Maven, use the following:
<dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>32.1.1-jre</version> <!-- or, for Android: --> <version>32.1.1-android</version> </dependency>
To add a dependency using Gradle:
dependencies { // Pick one: // 1. Use Guava in your implementation only: implementation("com.google.guava:guava:32.1.1-jre") // 2. Use Guava types in your public API: api("com.google.guava:guava:32.1.1-jre") // 3. Android - Use Guava in your implementation only: implementation("com.google.guava:guava:32.1.1-android") // 4. Android - Use Guava types in your public API: api("com.google.guava:guava:32.1.1-android") }
For more information on when to use api
and when to use implementation
, consult the Gradle documentation on API and implementation separation.
Snapshots of Guava built from the master
branch are available through Maven using version HEAD-jre-SNAPSHOT
, or HEAD-android-SNAPSHOT
for the Android flavor.
APIs marked with the @Beta
annotation at the class or method level are subject to change. They can be modified in any way, or even removed, at any time. If your code is a library itself (i.e., it is used on the CLASSPATH of users outside your own control), you should not use beta APIs unless you repackage them. If your code is a library, we strongly recommend using the Guava Beta Checker to ensure that you do not use any @Beta
APIs!
APIs without @Beta
will remain binary-compatible for the indefinite future. (Previously, we sometimes removed such APIs after a deprecation period. The last release to remove non-@Beta
APIs was Guava 21.0.) Even @Deprecated
APIs will remain (again, unless they are @Beta
). We have no plans to start removing things again, but officially, we're leaving our options open in case of surprises (like, say, a serious security problem).
Guava has one dependency that is needed for linkage at runtime: com.google.guava:failureaccess:1.0.1
. It also has some annotation-only dependencies, which we discuss in more detail at that link.
Serialized forms of ALL objects are subject to change unless noted otherwise. Do not persist these and assume they can be read by a future version of the library.
Our classes are not designed to protect against a malicious caller. You should not use them for communication between trusted and untrusted code.
For the mainline flavor, we test the libraries using OpenJDK 8, 11, and 17 on Linux, with some additional testing on newer JDKs and on Windows. Some features, especially in com.google.common.io
, may not work correctly in non-Linux environments. For the Android flavor, our unit tests also run on API level 15 (Ice Cream Sandwich).