diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 000000000000..1e956d2faa00
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,16 @@
+version: 2
+updates:
+# TODO(b/170636568): Enable Maven updates? Perhaps wait until we can more
+# easily import the generated PRs into our internal repo.
+# - package-ecosystem: "maven"
+# directory: "/"
+# schedule:
+# interval: "daily"
+# - package-ecosystem: "maven"
+# directory: "/android"
+# schedule:
+# interval: "daily"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "daily"
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index f3e07268881d..e0907fc21b4e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -13,28 +13,34 @@ jobs:
name: "${{ matrix.root-pom }} on JDK ${{ matrix.java }}"
strategy:
matrix:
- java: [ 8, 11 ]
+ java: [ 11, 17 ]
root-pom: [ 'pom.xml', 'android/pom.xml' ]
runs-on: ubuntu-latest
env:
ROOT_POM: ${{ matrix.root-pom }}
steps:
+ # Cancel any previous runs for the same branch that are still running.
+ - name: 'Cancel previous runs'
+ uses: styfle/cancel-workflow-action@0.9.1
+ with:
+ access_token: ${{ github.token }}
- name: 'Check out repository'
- uses: actions/checkout@v2
+ uses: actions/checkout@v2.4.0
- name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.4
+ uses: actions/cache@v2.1.7
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: 'Set up JDK ${{ matrix.java }}'
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
+ distribution: 'zulu'
- name: 'Install'
shell: bash
- run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -DskipTests=true -f $ROOT_POM
+ run: mvn -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn install -U -Dmaven.test.skip -Dmaven.javadoc.skip -f $ROOT_POM
- name: 'Test'
shell: bash
run: MAVEN_OPTS=-Xmx6g mvn -B -P!standard-with-extra-repos verify -U -Dmaven.javadoc.skip=true -f $ROOT_POM
@@ -51,18 +57,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
- uses: actions/checkout@v2
+ uses: actions/checkout@v2.4.0
- name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.4
+ uses: actions/cache@v2.1.7
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: 'Set up JDK 11'
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
java-version: 11
+ distribution: 'zulu'
server-id: sonatype-nexus-snapshots
server-username: CI_DEPLOY_USERNAME
server-password: CI_DEPLOY_PASSWORD
@@ -79,18 +86,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Check out repository'
- uses: actions/checkout@v2
+ uses: actions/checkout@v2.4.0
- name: 'Cache local Maven repository'
- uses: actions/cache@v2.1.4
+ uses: actions/cache@v2.1.7
with:
path: ~/.m2/repository
key: maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
maven-
- name: 'Set up JDK 11'
- uses: actions/setup-java@v1
+ uses: actions/setup-java@v2
with:
java-version: 11
+ distribution: 'zulu'
- name: 'Generate latest docs'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/README-typetools.md b/README-typetools.md
index 5c191148d14c..62dec84f125b 100644
--- a/README-typetools.md
+++ b/README-typetools.md
@@ -13,10 +13,34 @@ To create file `guava/target/guava-HEAD-jre-SNAPSHOT.jar`:
(cd guava && mvn -B package -Dmaven.test.skip=true -Danimal.sniffer.skip=true)
```
-To use a locally-built Checker Framework, add `-P checkerframework-local`,
+To use a locally-built Checker Framework:
+```
+(cd guava && mvn -B package -Dmaven.test.skip=true -Danimal.sniffer.skip=true -P checkerframework-local)
+```
or change `guava/pom.xml`.
+To run the Guava test suite
+---------------------------
+
+This not strictly necessary as the CI process will run them. But if you wish to do so,
+it is a two step process. This can take a long time: 20-30 minutes for the compile step
+and 30-35 minutes for the test step. In order to shorten it a bit, the command lines
+below only run a single format checker. First, you must run maven with the install
+target to get a copy of all the generated jar files in your local maven repository:
+
+mvn -V -B -U clean install -Dcheckerframework.checkers=org.checkerframework.checker.formatter.FormatterChecker \
+ -Dcheck.value.phase=skip -Dmaven.test.skip -Dmaven.javadoc.skip
+
+Then you run the test suite:
+
+MAVEN_OPTS=-Xmx6g mvn -V -B -U verify -Dcheckerframework.checkers=org.checkerframework.checker.formatter.FormatterChecker \
+ -Dcheck.value.phase=skip -Dmaven.javadoc.skip
+
+Running with the single FormatterChecker gets the total time down to about 20-25 minutes,
+almost all testing. (Over 850,000 tests are run.)
+
+
Typechecking
------------
@@ -68,6 +92,10 @@ Whenever a Checker Framework release is made:
To update to a newer version of the upstream library
----------------------------------------------------
+First, update to use the latest Checker Framework by editing file
+`pom.xml` (for `checker-qual`) and `guava/pom.xml` (for `checker`).
+Make a pull request to ensure that type-checking succeeds.
+
Check for a release at
https://github.com/google/guava/releases
. If there has been one since the last time this repository was pulled,
@@ -80,8 +108,9 @@ git pull https://github.com/google/guava
```
and then re-build to ensure that typechecking still works.
-Doing this `git pull` permits incremental resolution of merge conflicts,
-but makes it difficult to re-release a given version of Guava.
+Note: Doing this `git pull` command
+makes it difficult to re-release a given version of Guava,
+compared to pulling in the tag corresponding to a release.
If you wish to see a simplified diff between this fork of Guava and upstream (to make sure that you did not make any mistakes when resolving merge conflicts):
@@ -143,7 +172,7 @@ yet written.
2. Pull in the latest Guava version (https://github.com/google/guava/releases):
```
git fetch --tags https://github.com/google/guava
-git pull https://github.com/google/guava v30.1.1
+git pull https://github.com/google/guava v31.1
```
3. Ensure that the project still builds:
diff --git a/README.md b/README.md
index 67b5a937d05a..8afda8fbb9e0 100644
--- a/README.md
+++ b/README.md
@@ -9,11 +9,11 @@ utilities for concurrency, I/O, hashing, caching, primitives, strings, and more!
is widely used on most Java projects within Google, and widely used by many
other companies as well.
-Guava comes in two flavors.
+Guava comes in two flavors:
* The JRE flavor requires JDK 1.8 or higher.
-* If you need support for JDK 1.7 or Android, use the Android flavor. You can
- find the Android Guava source in the [`android` directory].
+* If you need support for Android, use the Android flavor. You can find the
+ Android Guava source in the [`android` directory].
[`android` directory]: https://github.com/google/guava/tree/master/android
@@ -21,9 +21,9 @@ Guava comes in two flavors.
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 Java 7 or by any library that wants to be compatible with
-either of those. These flavors are specified in the Maven version field as
-either `30.1-jre` or `30.1-android`. For more about depending on Guava, see
+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 `31.1-jre` or
+`31.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:
@@ -32,9 +32,9 @@ To add a dependency on Guava using Maven, use the following:
com.google.guava
guava
- 30.1-jre
+ 31.1-jre
- 30.1-android
+ 31.1-android
```
@@ -45,16 +45,16 @@ dependencies {
// Pick one:
// 1. Use Guava in your implementation only:
- implementation("com.google.guava:guava:30.1-jre")
+ implementation("com.google.guava:guava:31.1-jre")
// 2. Use Guava types in your public API:
- api("com.google.guava:guava:30.1-jre")
+ api("com.google.guava:guava:31.1-jre")
// 3. Android - Use Guava in your implementation only:
- implementation("com.google.guava:guava:30.1-android")
+ implementation("com.google.guava:guava:31.1-android")
// 4. Android - Use Guava types in your public API:
- api("com.google.guava:guava:30.1-android")
+ api("com.google.guava:guava:31.1-android")
}
```
@@ -101,8 +101,10 @@ flavor.
plans to start removing things again, but officially, we're leaving our
options open in case of surprises (like, say, a serious security problem).
-3. Guava has one dependency that is needed at runtime:
- `com.google.guava:failureaccess:1.0.1`
+3. 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][guava-deps], which we discuss in more
+ detail at that link.
4. 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
@@ -111,10 +113,10 @@ flavor.
5. Our classes are not designed to protect against a malicious caller. You
should not use them for communication between trusted and untrusted code.
-6. For the mainline flavor, we unit-test the libraries using only OpenJDK 1.8
- on Linux. Some features, especially in `com.google.common.io`, may not work
- correctly in other environments. For the Android flavor, our unit tests run
- on API level 15 (Ice Cream Sandwich).
+6. For the mainline flavor, we test the libraries using only OpenJDK 8 and
+ OpenJDK 11 on Linux. Some features, especially in `com.google.common.io`,
+ may not work correctly in other environments. For the Android flavor, our
+ unit tests also run on API level 15 (Ice Cream Sandwich).
[guava-snapshot-api-docs]: https://guava.dev/releases/snapshot-jre/api/docs/
[guava-snapshot-api-diffs]: https://guava.dev/releases/snapshot-jre/api/diffs/
@@ -125,3 +127,4 @@ flavor.
[using Guava in your build]: https://github.com/google/guava/wiki/UseGuavaInYourBuild
[repackage]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-if-i-want-to-use-beta-apis-from-a-library-that-people-use-as-a-dependency
+[guava-deps]: https://github.com/google/guava/wiki/UseGuavaInYourBuild#what-about-guavas-own-dependencies
diff --git a/android/guava-bom/pom.xml b/android/guava-bom/pom.xml
index 8fde93d1a75a..736c02fd8044 100644
--- a/android/guava-bom/pom.xml
+++ b/android/guava-bom/pom.xml
@@ -8,7 +8,7 @@
com.google.guava
guava-bom
- HEAD-android-SNAPSHOT
+ 31.1-android
pom
diff --git a/android/guava-testlib/pom.xml b/android/guava-testlib/pom.xml
index 79b05190ce85..1fcf058676ee 100644
--- a/android/guava-testlib/pom.xml
+++ b/android/guava-testlib/pom.xml
@@ -5,7 +5,7 @@
com.google.guava
guava-parent
- HEAD-android-SNAPSHOT
+ 31.1-android
guava-testlib
Guava Testing Library
@@ -18,10 +18,6 @@
com.google.code.findbugs
jsr305
-
- org.checkerframework
- checker-compat-qual
-
com.google.errorprone
error_prone_annotations
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java b/android/guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java
index a5674d3db4d0..b86ef1750dee 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java
@@ -188,7 +188,7 @@ protected ArrayWithDuplicate createArrayWithDuplicateElement() {
E[] elements = createSamplesArray();
E duplicate = elements[(elements.length / 2) - 1];
elements[(elements.length / 2) + 1] = duplicate;
- return new ArrayWithDuplicate(elements, duplicate);
+ return new ArrayWithDuplicate<>(elements, duplicate);
}
// Helper methods to improve readability of derived classes
@@ -211,7 +211,7 @@ protected Collection getSampleElements() {
* requirement {@link com.google.common.collect.testing.features.CollectionFeature#KNOWN_ORDER}.
*/
protected List getOrderedElements() {
- List list = new ArrayList();
+ List list = new ArrayList<>();
for (E e : getSubjectGenerator().order(new ArrayList(getSampleElements()))) {
list.add(e);
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/AbstractMapTester.java b/android/guava-testlib/src/com/google/common/collect/testing/AbstractMapTester.java
index 090442edc4da..5e0de3ccc443 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/AbstractMapTester.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/AbstractMapTester.java
@@ -72,8 +72,8 @@ protected void expectMissingValues(V... elements) {
/** @return an array of the proper size with {@code null} as the key of the middle element. */
protected Entry[] createArrayWithNullKey() {
Entry[] array = createSamplesArray();
- final int nullKeyLocation = getNullLocation();
- final Entry oldEntry = array[nullKeyLocation];
+ int nullKeyLocation = getNullLocation();
+ Entry oldEntry = array[nullKeyLocation];
array[nullKeyLocation] = entry(null, oldEntry.getValue());
return array;
}
@@ -97,8 +97,8 @@ private Entry getEntryNullReplaces() {
/** @return an array of the proper size with {@code null} as the value of the middle element. */
protected Entry[] createArrayWithNullValue() {
Entry[] array = createSamplesArray();
- final int nullValueLocation = getNullLocation();
- final Entry oldEntry = array[nullValueLocation];
+ int nullValueLocation = getNullLocation();
+ Entry oldEntry = array[nullValueLocation];
array[nullValueLocation] = entry(oldEntry.getKey(), null);
return array;
}
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java b/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
index cf1ed23aa41e..5f9aff4f1c5f 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/CollectionTestSuiteBuilder.java
@@ -57,6 +57,8 @@ protected List createDerivedSuites(
.named(getName() + " reserialized")
.withFeatures(computeReserializedCollectionFeatures(parentBuilder.getFeatures()))
.suppressing(parentBuilder.getSuppressedTests())
+ .withSetUp(parentBuilder.getSetUp())
+ .withTearDown(parentBuilder.getTearDown())
.createTestSuite());
}
return derivedSuites;
diff --git a/android/guava-testlib/src/com/google/common/collect/testing/DerivedCollectionGenerators.java b/android/guava-testlib/src/com/google/common/collect/testing/DerivedCollectionGenerators.java
index 3588e856fa23..a04d3ffe300a 100644
--- a/android/guava-testlib/src/com/google/common/collect/testing/DerivedCollectionGenerators.java
+++ b/android/guava-testlib/src/com/google/common/collect/testing/DerivedCollectionGenerators.java
@@ -96,9 +96,9 @@ public static class MapKeySetGenerator implements TestSetGenerator, Der
public MapKeySetGenerator(OneSizeTestContainerGenerator