From 6a50a63ca8ab8e59b0c90a5c6940fde1c063f5c2 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 29 Apr 2020 16:46:00 -0700 Subject: [PATCH] Replace javax.annotation-api with Tomcat's annotations-api javax.annotation-api is licensed CDDL, which was not noticed when it was introduced. Tomcat provides an Apache 2 version of the same annotation. Note that this annotation is only used when compiling with Java 9+. Unfortunately this may cause classpath collisions since there are _many_ copies of this annotation on Maven Central; we wanted one canonical source and javax.annotation-api seemed like that source. We hope this won't impact many users since we have always suggested using it only for compilation. But it will probably impact some users. However, we didn't create this mess, this seems to be "standard practice" for J2EE, which this annotation is now part of, so we're just impacted by it. Fixes #6833 --- build.gradle | 2 +- examples/android/clientcache/app/build.gradle | 2 +- examples/android/helloworld/app/build.gradle | 2 +- examples/android/routeguide/app/build.gradle | 2 +- examples/android/strictmode/app/build.gradle | 2 +- examples/build.gradle | 2 +- examples/example-alts/build.gradle | 2 +- examples/example-gauth/build.gradle | 2 +- examples/example-gauth/pom.xml | 6 ++--- examples/example-hostname/build.gradle | 2 +- examples/example-hostname/pom.xml | 6 ++--- examples/example-jwt-auth/build.gradle | 2 +- examples/example-jwt-auth/pom.xml | 6 ++--- examples/example-tls/build.gradle | 2 +- examples/example-tls/pom.xml | 6 ++--- examples/pom.xml | 6 ++--- repositories.bzl | 26 +++++++++---------- services/BUILD.bazel | 1 - stub/BUILD.bazel | 2 +- 19 files changed, 40 insertions(+), 41 deletions(-) diff --git a/build.gradle b/build.gradle index f3fd918076..c3549fd053 100644 --- a/build.gradle +++ b/build.gradle @@ -138,7 +138,7 @@ subprojects { gson: "com.google.code.gson:gson:2.8.6", guava: "com.google.guava:guava:${guavaVersion}", hpack: 'com.twitter:hpack:0.10.1', - javax_annotation: 'javax.annotation:javax.annotation-api:1.2', + javax_annotation: 'org.apache.tomcat:annotations-api:6.0.53', jsr305: 'com.google.code.findbugs:jsr305:3.0.2', google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.17.0', google_auth_credentials: "com.google.auth:google-auth-library-credentials:${googleauthVersion}", diff --git a/examples/android/clientcache/app/build.gradle b/examples/android/clientcache/app/build.gradle index b03ec45f86..108bbda1ad 100644 --- a/examples/android/clientcache/app/build.gradle +++ b/examples/android/clientcache/app/build.gradle @@ -53,7 +53,7 @@ dependencies { implementation 'io.grpc:grpc-okhttp:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'org.apache.tomcat:annotations-api:6.0.53' testImplementation 'junit:junit:4.12' testImplementation 'com.google.truth:truth:1.0.1' diff --git a/examples/android/helloworld/app/build.gradle b/examples/android/helloworld/app/build.gradle index 43a25633f8..332954b2dd 100644 --- a/examples/android/helloworld/app/build.gradle +++ b/examples/android/helloworld/app/build.gradle @@ -52,5 +52,5 @@ dependencies { implementation 'io.grpc:grpc-okhttp:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/routeguide/app/build.gradle b/examples/android/routeguide/app/build.gradle index 698557f09b..4b0dd53f7f 100644 --- a/examples/android/routeguide/app/build.gradle +++ b/examples/android/routeguide/app/build.gradle @@ -51,5 +51,5 @@ dependencies { implementation 'io.grpc:grpc-okhttp:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/android/strictmode/app/build.gradle b/examples/android/strictmode/app/build.gradle index fd8284aca8..601b2fbb2d 100644 --- a/examples/android/strictmode/app/build.gradle +++ b/examples/android/strictmode/app/build.gradle @@ -52,5 +52,5 @@ dependencies { implementation 'io.grpc:grpc-okhttp:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.30.0-SNAPSHOT' // CURRENT_GRPC_VERSION - implementation 'javax.annotation:javax.annotation-api:1.2' + implementation 'org.apache.tomcat:annotations-api:6.0.53' } diff --git a/examples/build.gradle b/examples/build.gradle index 919001774c..839db31c91 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -29,7 +29,7 @@ def protocVersion = protobufVersion dependencies { implementation "io.grpc:grpc-protobuf:${grpcVersion}" implementation "io.grpc:grpc-stub:${grpcVersion}" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" // examples/advanced need this for JsonFormat implementation "com.google.protobuf:protobuf-java-util:${protobufVersion}" diff --git a/examples/example-alts/build.gradle b/examples/example-alts/build.gradle index 717d8c1cf4..84e37df668 100644 --- a/examples/example-alts/build.gradle +++ b/examples/example-alts/build.gradle @@ -29,7 +29,7 @@ def protocVersion = '3.11.0' dependencies { // grpc-alts transitively depends on grpc-netty-shaded, grpc-protobuf, and grpc-stub implementation "io.grpc:grpc-alts:${grpcVersion}" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" } protobuf { diff --git a/examples/example-gauth/build.gradle b/examples/example-gauth/build.gradle index 01d01524c2..b556de8553 100644 --- a/examples/example-gauth/build.gradle +++ b/examples/example-gauth/build.gradle @@ -32,7 +32,7 @@ dependencies { implementation "io.grpc:grpc-protobuf:${grpcVersion}" implementation "io.grpc:grpc-stub:${grpcVersion}" implementation "io.grpc:grpc-auth:${grpcVersion}" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" implementation "com.google.auth:google-auth-library-oauth2-http:0.9.0" implementation "com.google.api.grpc:grpc-google-cloud-pubsub-v1:0.1.24" runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" diff --git a/examples/example-gauth/pom.xml b/examples/example-gauth/pom.xml index e1916c0a1f..70f8ebeabb 100644 --- a/examples/example-gauth/pom.xml +++ b/examples/example-gauth/pom.xml @@ -50,9 +50,9 @@ grpc-auth - javax.annotation - javax.annotation-api - 1.2 + org.apache.tomcat + annotations-api + 6.0.53 provided diff --git a/examples/example-hostname/build.gradle b/examples/example-hostname/build.gradle index a55d7fcaed..6d1c824a81 100644 --- a/examples/example-hostname/build.gradle +++ b/examples/example-hostname/build.gradle @@ -27,7 +27,7 @@ dependencies { implementation "io.grpc:grpc-protobuf:${grpcVersion}" implementation "io.grpc:grpc-stub:${grpcVersion}" implementation "io.grpc:grpc-services:${grpcVersion}" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" testImplementation 'junit:junit:4.12' diff --git a/examples/example-hostname/pom.xml b/examples/example-hostname/pom.xml index 80557102f4..e26da43655 100644 --- a/examples/example-hostname/pom.xml +++ b/examples/example-hostname/pom.xml @@ -45,9 +45,9 @@ grpc-services - javax.annotation - javax.annotation-api - 1.2 + org.apache.tomcat + annotations-api + 6.0.53 provided diff --git a/examples/example-jwt-auth/build.gradle b/examples/example-jwt-auth/build.gradle index e19dd9e94d..366cb8d33c 100644 --- a/examples/example-jwt-auth/build.gradle +++ b/examples/example-jwt-auth/build.gradle @@ -32,7 +32,7 @@ dependencies { implementation "io.jsonwebtoken:jjwt:0.9.1" implementation "javax.xml.bind:jaxb-api:2.3.1" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" runtimeOnly "io.grpc:grpc-netty-shaded:${grpcVersion}" diff --git a/examples/example-jwt-auth/pom.xml b/examples/example-jwt-auth/pom.xml index 07c89cc5b2..c5223cb488 100644 --- a/examples/example-jwt-auth/pom.xml +++ b/examples/example-jwt-auth/pom.xml @@ -58,9 +58,9 @@ 2.3.1 - javax.annotation - javax.annotation-api - 1.2 + org.apache.tomcat + annotations-api + 6.0.53 provided diff --git a/examples/example-tls/build.gradle b/examples/example-tls/build.gradle index d023ae4672..458010c80e 100644 --- a/examples/example-tls/build.gradle +++ b/examples/example-tls/build.gradle @@ -31,7 +31,7 @@ dependencies { implementation "io.grpc:grpc-netty:${grpcVersion}" implementation "io.grpc:grpc-protobuf:${grpcVersion}" implementation "io.grpc:grpc-stub:${grpcVersion}" - compileOnly "javax.annotation:javax.annotation-api:1.2" + compileOnly "org.apache.tomcat:annotations-api:6.0.53" runtimeOnly "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}" } diff --git a/examples/example-tls/pom.xml b/examples/example-tls/pom.xml index c535c25788..db22206079 100644 --- a/examples/example-tls/pom.xml +++ b/examples/example-tls/pom.xml @@ -42,9 +42,9 @@ grpc-stub - javax.annotation - javax.annotation-api - 1.2 + org.apache.tomcat + annotations-api + 6.0.53 provided diff --git a/examples/pom.xml b/examples/pom.xml index f12ef96351..de93df25ca 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -47,9 +47,9 @@ grpc-stub - javax.annotation - javax.annotation-api - 1.2 + org.apache.tomcat + annotations-api + 6.0.53 provided diff --git a/repositories.bzl b/repositories.bzl index 9dac4ad17c..642f2bd94e 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -39,9 +39,9 @@ IO_GRPC_GRPC_JAVA_ARTIFACTS = [ "io.opencensus:opencensus-api:0.24.0", "io.opencensus:opencensus-contrib-grpc-metrics:0.24.0", "io.perfmark:perfmark-api:0.19.0", - "javax.annotation:javax.annotation-api:1.2", "junit:junit:4.12", "org.apache.commons:commons-lang3:3.5", + "org.apache.tomcat:annotations-api:6.0.53", "org.codehaus.mojo:animal-sniffer-annotations:1.18", ] @@ -148,12 +148,12 @@ def grpc_java_repositories(): io_opencensus_opencensus_contrib_grpc_metrics() if not native.existing_rule("io_perfmark_perfmark_api"): io_perfmark_perfmark_api() - if not native.existing_rule("javax_annotation_javax_annotation_api"): - javax_annotation_javax_annotation_api() if not native.existing_rule("junit_junit"): junit_junit() if not native.existing_rule("org_apache_commons_commons_lang3"): org_apache_commons_commons_lang3() + if not native.existing_rule("org_apache_tomcat_annotations_api"): + org_apache_tomcat_annotations_api() if not native.existing_rule("org_codehaus_mojo_animal_sniffer_annotations"): org_codehaus_mojo_animal_sniffer_annotations() @@ -451,16 +451,6 @@ def io_perfmark_perfmark_api(): licenses = ["notice"], # Apache 2.0 ) -def javax_annotation_javax_annotation_api(): - # Use //stub:javax_annotation for neverlink=1 support. - jvm_maven_import_external( - name = "javax_annotation_javax_annotation_api", - artifact = "javax.annotation:javax.annotation-api:1.2", - server_urls = ["https://repo.maven.apache.org/maven2/"], - artifact_sha256 = "5909b396ca3a2be10d0eea32c74ef78d816e1b4ead21de1d78de1f890d033e04", - licenses = ["reciprocal"], # CDDL License - ) - def junit_junit(): jvm_maven_import_external( name = "junit_junit", @@ -479,6 +469,16 @@ def org_apache_commons_commons_lang3(): licenses = ["notice"], # Apache 2.0 ) +def org_apache_tomcat_annotations_api(): + # Use //stub:javax_annotation for neverlink=1 support. + jvm_maven_import_external( + name = "org_apache_tomcat_annotations_api", + artifact = "org.apache.tomcat:annotations-api:6.0.53", + server_urls = ["https://repo.maven.apache.org/maven2/"], + artifact_sha256 = "253829d3c12b7381d1044fc22c6436cff025fe0d459e4a329413e560a7d0dd13", + licenses = ["notice"], # Apache 2.0 + ) + def org_codehaus_mojo_animal_sniffer_annotations(): jvm_maven_import_external( name = "org_codehaus_mojo_animal_sniffer_annotations", diff --git a/services/BUILD.bazel b/services/BUILD.bazel index 5b31c974a2..97b5120ccd 100644 --- a/services/BUILD.bazel +++ b/services/BUILD.bazel @@ -60,7 +60,6 @@ java_library( "@com_google_protobuf//:protobuf_java", "@com_google_protobuf//:protobuf_java_util", "@io_grpc_grpc_proto//:reflection_java_proto_deprecated", - "@javax_annotation_javax_annotation_api//jar", ], ) diff --git a/stub/BUILD.bazel b/stub/BUILD.bazel index f4cfaf004d..181ffe0485 100644 --- a/stub/BUILD.bazel +++ b/stub/BUILD.bazel @@ -19,5 +19,5 @@ java_library( name = "javax_annotation", neverlink = 1, # @Generated is source-retention visibility = ["//visibility:public"], - exports = ["@javax_annotation_javax_annotation_api//jar"], + exports = ["@org_apache_tomcat_annotations_api//jar"], )