diff --git a/api/BUILD.bazel b/api/BUILD.bazel index 34e8de95335..6bf3375e9f0 100644 --- a/api/BUILD.bazel +++ b/api/BUILD.bazel @@ -13,6 +13,5 @@ java_library( artifact("com.google.errorprone:error_prone_annotations"), artifact("com.google.guava:failureaccess"), # future transitive dep of Guava. See #5214 artifact("com.google.guava:guava"), - artifact("org.codehaus.mojo:animal-sniffer-annotations"), ], ) diff --git a/api/build.gradle b/api/build.gradle index 6a75597ed55..dc3eaea3f4e 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -36,7 +36,6 @@ tasks.named("jar").configure { dependencies { compileOnly sourceSets.context.output api libraries.jsr305, - libraries.animalsniffer.annotations, libraries.errorprone.annotations implementation libraries.guava @@ -61,6 +60,10 @@ dependencies { } } +animalsniffer { + annotation = 'io.grpc.IgnoreJRERequirement' +} + tasks.named("javadoc").configure { source sourceSets.context.allSource // We want io.grpc.Internal, but not io.grpc.Internal* diff --git a/api/src/main/java/io/grpc/IgnoreJRERequirement.java b/api/src/main/java/io/grpc/IgnoreJRERequirement.java new file mode 100644 index 00000000000..2db406c5953 --- /dev/null +++ b/api/src/main/java/io/grpc/IgnoreJRERequirement.java @@ -0,0 +1,30 @@ +/* + * Copyright 2024 The gRPC 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 io.grpc; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; + +/** + * Disables Animal Sniffer's signature checking. This is our own package-private version to avoid + * dependening on animalsniffer-annotations. + * + *
FIELD is purposefully not supported, as Android wouldn't be able to ignore a field. Instead,
+ * the entire class would need to be avoided on Android.
+ */
+@Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE})
+@interface IgnoreJRERequirement {}
diff --git a/api/src/main/java/io/grpc/TimeUtils.java b/api/src/main/java/io/grpc/TimeUtils.java
index c3cdf843d79..01b8c158822 100644
--- a/api/src/main/java/io/grpc/TimeUtils.java
+++ b/api/src/main/java/io/grpc/TimeUtils.java
@@ -17,7 +17,6 @@
package io.grpc;
import java.time.Duration;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
final class TimeUtils {
private TimeUtils() {}
diff --git a/api/src/test/java/io/grpc/CallOptionsTest.java b/api/src/test/java/io/grpc/CallOptionsTest.java
index 051c1b2d851..65fb7ff3bf2 100644
--- a/api/src/test/java/io/grpc/CallOptionsTest.java
+++ b/api/src/test/java/io/grpc/CallOptionsTest.java
@@ -34,7 +34,6 @@
import io.grpc.internal.SerializingExecutor;
import java.time.Duration;
import java.util.concurrent.Executor;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
diff --git a/api/src/test/java/io/grpc/SynchronizationContextTest.java b/api/src/test/java/io/grpc/SynchronizationContextTest.java
index d063c58a978..668f5ae4d6d 100644
--- a/api/src/test/java/io/grpc/SynchronizationContextTest.java
+++ b/api/src/test/java/io/grpc/SynchronizationContextTest.java
@@ -36,7 +36,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.After;
import org.junit.Rule;
import org.junit.Test;
diff --git a/api/src/test/java/io/grpc/TimeUtilsTest.java b/api/src/test/java/io/grpc/TimeUtilsTest.java
index 75c0437ce26..728b8512cd7 100644
--- a/api/src/test/java/io/grpc/TimeUtilsTest.java
+++ b/api/src/test/java/io/grpc/TimeUtilsTest.java
@@ -19,7 +19,6 @@
import static org.junit.Assert.assertEquals;
import java.time.Duration;
-import org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
diff --git a/buildscripts/checkstyle.xml b/buildscripts/checkstyle.xml
index 035b1dfc900..0ec8ecc79ce 100644
--- a/buildscripts/checkstyle.xml
+++ b/buildscripts/checkstyle.xml
@@ -38,6 +38,12 @@