Set `-source 8 -target 8` in the open-source build, and remove Java8Usage.

This is largely a rollback of the original Java8Usage change, but I've modified it in a few ways:

- I set `-source 8 -target 8` in the backport.
- I kept the code to make includes/excludes fully work with maven-compiler-plugin, since that could save us some confusion down the line.
- I incorporated a rollback of the changes to Preconditions from CL 361700569, in which I moved the warning from MoreObjects to Preconditions.
- I added errors to our internal release scripts so that we don't accidentally make a release that drops Java 7 support before we're ready.

Fixes https://github.com/google/guava/issues/5269

PiperOrigin-RevId: 364614257
diff --git a/android/guava/pom.xml b/android/guava/pom.xml
index 2997108..ed15b82 100644
--- a/android/guava/pom.xml
+++ b/android/guava/pom.xml
@@ -90,42 +90,6 @@
       </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
-        <executions>
-          <execution>
-            <!--
-                 The execution named default-compile happens first, regardless
-                 of the order of the executions in the source file. So, because
-                 Java8Usage is a dependency of the main sources, we need to call
-                 its compilation "default-compile," even though it's the special
-                 case.
-            -->
-            <id>default-compile</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-            <configuration>
-              <includes>
-                <include>**/Java8Usage.java</include>
-              </includes>
-              <!-- -source 8 -target 8 is a no-op in the mainline but matters in the backport. -->
-              <source>8</source>
-              <target>8</target>
-            </configuration>
-          </execution>
-          <execution>
-            <id>main-compile</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-            <configuration>
-              <excludes>
-                <exclude>**/Java8Usage.java</exclude>
-              </excludes>
-            </configuration>
-          </execution>
-        </executions>
       </plugin>
       <plugin>
         <artifactId>maven-source-plugin</artifactId>
diff --git a/android/guava/src/com/google/common/base/Java8Usage.java b/android/guava/src/com/google/common/base/Java8Usage.java
deleted file mode 100755
index 78130cf..0000000
--- a/android/guava/src/com/google/common/base/Java8Usage.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.errorprone.annotations.CanIgnoreReturnValue;
-
-/**
- * A class that uses a couple Java 8 features but doesn't really do anything. This lets us attempt
- * to load it and log a warning if that fails, giving users advance notice of our dropping Java 8
- * support.
- */
-/*
- * This class should be annotated @GwtCompatible. But if we annotate it @GwtCompatible, then we need
- * to build GwtCompatible.java (-source 7 -target 7 in the Android flavor) before we build
- * Java8Usage.java (-source 8 target 8, which we already need to build before the rest of
- * common.base). We could configure Maven to do that, but it's easier to just skip the annotation.
- */
-final class Java8Usage {
-  @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
-  @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
-  private @interface SomeTypeAnnotation {}
-
-  @CanIgnoreReturnValue
-  static @SomeTypeAnnotation String performCheck() {
-    Runnable r = () -> {};
-    r.run();
-    return "";
-  }
-
-  private Java8Usage() {}
-}
diff --git a/android/guava/src/com/google/common/base/Preconditions.java b/android/guava/src/com/google/common/base/Preconditions.java
index 38f6654..995d394 100644
--- a/android/guava/src/com/google/common/base/Preconditions.java
+++ b/android/guava/src/com/google/common/base/Preconditions.java
@@ -15,11 +15,9 @@
 package com.google.common.base;
 
 import static com.google.common.base.Strings.lenientFormat;
-import static java.util.logging.Level.WARNING;
 
 import com.google.common.annotations.GwtCompatible;
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.util.logging.Logger;
 import org.checkerframework.checker.nullness.compatqual.NonNullDecl;
 import org.checkerframework.checker.nullness.compatqual.NullableDecl;
 
@@ -1490,21 +1488,4 @@
     // end < start
     return lenientFormat("end index (%s) must not be less than start index (%s)", end, start);
   }
-
-  static {
-    try {
-      Java8Usage.performCheck();
-    } catch (Throwable underlying) {
-      Exception toLog =
-          new Exception(
-              "Guava will drop support for Java 7 in 2021. Please let us know if this will cause"
-                  + " you problems: https://github.com/google/guava/issues/5269",
-              underlying);
-      Logger.getLogger(Preconditions.class.getName())
-          .log(
-              WARNING,
-              "Java 7 compatibility warning: See https://github.com/google/guava/issues/5269",
-              toLog);
-    }
-  }
 }
diff --git a/android/pom.xml b/android/pom.xml
index 96d2bd7..c802ca3 100644
--- a/android/pom.xml
+++ b/android/pom.xml
@@ -132,8 +132,8 @@
           <artifactId>maven-compiler-plugin</artifactId>
           <version>3.8.1</version>
           <configuration>
-            <source>1.7</source>
-            <target>1.7</target>
+            <source>1.8</source>
+            <target>1.8</target>
             <compilerArgs>
               <!--
                    Make includes/excludes fully work:
diff --git a/guava/pom.xml b/guava/pom.xml
index d95559c..4a7cd5c 100644
--- a/guava/pom.xml
+++ b/guava/pom.xml
@@ -90,42 +90,6 @@
       </plugin>
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
-        <executions>
-          <execution>
-            <!--
-                 The execution named default-compile happens first, regardless
-                 of the order of the executions in the source file. So, because
-                 Java8Usage is a dependency of the main sources, we need to call
-                 its compilation "default-compile," even though it's the special
-                 case.
-            -->
-            <id>default-compile</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-            <configuration>
-              <includes>
-                <include>**/Java8Usage.java</include>
-              </includes>
-              <!-- -source 8 -target 8 is a no-op in the mainline but matters in the backport. -->
-              <source>8</source>
-              <target>8</target>
-            </configuration>
-          </execution>
-          <execution>
-            <id>main-compile</id>
-            <phase>compile</phase>
-            <goals>
-              <goal>compile</goal>
-            </goals>
-            <configuration>
-              <excludes>
-                <exclude>**/Java8Usage.java</exclude>
-              </excludes>
-            </configuration>
-          </execution>
-        </executions>
       </plugin>
       <plugin>
         <artifactId>maven-source-plugin</artifactId>
diff --git a/guava/src/com/google/common/base/Java8Usage.java b/guava/src/com/google/common/base/Java8Usage.java
deleted file mode 100644
index 78130cf..0000000
--- a/guava/src/com/google/common/base/Java8Usage.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2020 The Guava Authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.google.common.base;
-
-import com.google.errorprone.annotations.CanIgnoreReturnValue;
-
-/**
- * A class that uses a couple Java 8 features but doesn't really do anything. This lets us attempt
- * to load it and log a warning if that fails, giving users advance notice of our dropping Java 8
- * support.
- */
-/*
- * This class should be annotated @GwtCompatible. But if we annotate it @GwtCompatible, then we need
- * to build GwtCompatible.java (-source 7 -target 7 in the Android flavor) before we build
- * Java8Usage.java (-source 8 target 8, which we already need to build before the rest of
- * common.base). We could configure Maven to do that, but it's easier to just skip the annotation.
- */
-final class Java8Usage {
-  @java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
-  @java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
-  private @interface SomeTypeAnnotation {}
-
-  @CanIgnoreReturnValue
-  static @SomeTypeAnnotation String performCheck() {
-    Runnable r = () -> {};
-    r.run();
-    return "";
-  }
-
-  private Java8Usage() {}
-}
diff --git a/guava/src/com/google/common/base/Preconditions.java b/guava/src/com/google/common/base/Preconditions.java
index 3dd679d..30cc374 100644
--- a/guava/src/com/google/common/base/Preconditions.java
+++ b/guava/src/com/google/common/base/Preconditions.java
@@ -15,11 +15,9 @@
 package com.google.common.base;
 
 import static com.google.common.base.Strings.lenientFormat;
-import static java.util.logging.Level.WARNING;
 
 import com.google.common.annotations.GwtCompatible;
 import com.google.errorprone.annotations.CanIgnoreReturnValue;
-import java.util.logging.Logger;
 import org.checkerframework.checker.nullness.qual.NonNull;
 import org.checkerframework.checker.nullness.qual.Nullable;
 
@@ -1433,21 +1431,4 @@
     // end < start
     return lenientFormat("end index (%s) must not be less than start index (%s)", end, start);
   }
-
-  static {
-    try {
-      Java8Usage.performCheck();
-    } catch (Throwable underlying) {
-      Exception toLog =
-          new Exception(
-              "Guava will drop support for Java 7 in 2021. Please let us know if this will cause"
-                  + " you problems: https://github.com/google/guava/issues/5269",
-              underlying);
-      Logger.getLogger(Preconditions.class.getName())
-          .log(
-              WARNING,
-              "Java 7 compatibility warning: See https://github.com/google/guava/issues/5269",
-              toLog);
-    }
-  }
 }