From 380989b82d9fb128ad22ef09faee936bc2dce090 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 18 Dec 2019 14:29:15 -0800 Subject: [PATCH 1/3] repositories.bzl: Remove omit* args in favor of existing_rule() check Using existing_rule() is now the preferred way of avoiding re-defining repositories. The function names were changed to match the name of the repository they add. Normally we would inline all the functions, but that's unnecessary churn since the repositories will mostly be replaced with maven_install() in the future. --- repositories.bzl | 198 +++++++++++++++++++---------------------------- 1 file changed, 80 insertions(+), 118 deletions(-) diff --git a/repositories.bzl b/repositories.bzl index 760ba300b9f..e90a8860ddb 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -37,115 +37,77 @@ IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = { "io.grpc:grpc-testing": "@io_grpc_grpc_java//testing", } -def grpc_java_repositories( - omit_com_google_android_annotations = False, - omit_com_google_api_grpc_google_common_protos = False, - omit_com_google_auth_google_auth_library_credentials = False, - omit_com_google_auth_google_auth_library_oauth2_http = False, - omit_com_google_code_findbugs_jsr305 = False, - omit_com_google_code_gson = False, - omit_com_google_errorprone_error_prone_annotations = False, - omit_com_google_guava = False, - omit_com_google_guava_failureaccess = False, - omit_com_google_j2objc_j2objc_annotations = False, - omit_com_google_protobuf = False, - omit_com_google_protobuf_java = False, - omit_com_google_protobuf_javalite = False, - omit_com_google_truth_truth = False, - omit_com_squareup_okhttp = False, - omit_com_squareup_okio = False, - omit_io_grpc_grpc_proto = False, - omit_io_netty_buffer = False, - omit_io_netty_common = False, - omit_io_netty_transport = False, - omit_io_netty_transport_native_epoll = False, - omit_io_netty_codec = False, - omit_io_netty_codec_socks = False, - omit_io_netty_codec_http = False, - omit_io_netty_codec_http2 = False, - omit_io_netty_handler = False, - omit_io_netty_handler_proxy = False, - omit_io_netty_resolver = False, - omit_io_netty_tcnative_boringssl_static = False, - omit_io_opencensus_api = False, - omit_io_opencensus_grpc_metrics = False, - omit_io_perfmark = False, - omit_javax_annotation = False, - omit_junit_junit = False, - omit_org_apache_commons_lang3 = False, - omit_org_codehaus_mojo_animal_sniffer_annotations = False): +def grpc_java_repositories(): """Imports dependencies for grpc-java.""" - if not omit_com_google_android_annotations: + if not native.existing_rule("com_google_android_annotations"): com_google_android_annotations() - if not omit_com_google_api_grpc_google_common_protos: - com_google_api_grpc_google_common_protos() - if not omit_com_google_auth_google_auth_library_credentials: + if not native.existing_rule("com_google_api_grpc_proto_google_common_protos"): + com_google_api_grpc_proto_google_common_protos() + if not native.existing_rule("com_google_auth_google_auth_library_credentials"): com_google_auth_google_auth_library_credentials() - if not omit_com_google_auth_google_auth_library_oauth2_http: + if not native.existing_rule("com_google_auth_google_auth_library_oauth2_http"): com_google_auth_google_auth_library_oauth2_http() - if not omit_com_google_code_findbugs_jsr305: + if not native.existing_rule("com_google_code_findbugs_jsr305"): com_google_code_findbugs_jsr305() - if not omit_com_google_code_gson: - com_google_code_gson() - if not omit_com_google_errorprone_error_prone_annotations: + if not native.existing_rule("com_google_code_gson_gson"): + com_google_code_gson_gson() + if not native.existing_rule("com_google_errorprone_error_prone_annotations"): com_google_errorprone_error_prone_annotations() - if not omit_com_google_guava: - com_google_guava() - if not omit_com_google_guava_failureaccess: + if not native.existing_rule("com_google_guava_guava"): + com_google_guava_guava() + if not native.existing_rule("com_google_guava_failureaccess"): com_google_guava_failureaccess() - if not omit_com_google_j2objc_j2objc_annotations: + if not native.existing_rule("com_google_j2objc_j2objc_annotations"): com_google_j2objc_j2objc_annotations() - if not omit_com_google_protobuf: + if not native.existing_rule("com_google_protobuf"): com_google_protobuf() - if omit_com_google_protobuf_java: - fail("omit_com_google_protobuf_java is no longer supported and must be not be passed to grpc_java_repositories()") - if not omit_com_google_protobuf_javalite: + if not native.existing_rule("com_google_protobuf_javalite"): com_google_protobuf_javalite() - if not omit_com_google_truth_truth: + if not native.existing_rule("com_google_truth_truth"): com_google_truth_truth() - if not omit_com_squareup_okhttp: - com_squareup_okhttp() - if not omit_com_squareup_okio: - com_squareup_okio() - if not omit_io_grpc_grpc_proto: + if not native.existing_rule("io_grpc_grpc_proto"): io_grpc_grpc_proto() - if not omit_io_netty_buffer: - io_netty_buffer() - if not omit_io_netty_common: - io_netty_common() - if not omit_io_netty_transport: - io_netty_transport() - if not omit_io_netty_transport_native_epoll: - io_netty_transport_native_epoll() - if not omit_io_netty_codec: - io_netty_codec() - if not omit_io_netty_codec_socks: - io_netty_codec_socks() - if not omit_io_netty_codec_http: - io_netty_codec_http() - if not omit_io_netty_codec_http2: - io_netty_codec_http2() - if not omit_io_netty_handler: - io_netty_handler() - if not omit_io_netty_handler_proxy: - io_netty_handler_proxy() - if not omit_io_netty_resolver: - io_netty_resolver() - if not omit_io_netty_tcnative_boringssl_static: - io_netty_tcnative_boringssl_static() - if not omit_io_opencensus_api: - io_opencensus_api() - if not omit_io_opencensus_grpc_metrics: - io_opencensus_grpc_metrics() - if not omit_io_perfmark: - io_perfmark() - if not omit_javax_annotation: - javax_annotation() - if not omit_junit_junit: + if not native.existing_rule("com_squareup_okhttp_okhttp"): + com_squareup_okhttp_okhttp() + if not native.existing_rule("com_squareup_okio_okio"): + com_squareup_okio_okio() + if not native.existing_rule("io_netty_netty_buffer"): + io_netty_netty_buffer() + if not native.existing_rule("io_netty_netty_codec"): + io_netty_netty_codec() + if not native.existing_rule("io_netty_netty_codec_http"): + io_netty_netty_codec_http() + if not native.existing_rule("io_netty_netty_codec_http2"): + io_netty_netty_codec_http2() + if not native.existing_rule("io_netty_netty_codec_socks"): + io_netty_netty_codec_socks() + if not native.existing_rule("io_netty_netty_common"): + io_netty_netty_common() + if not native.existing_rule("io_netty_netty_handler"): + io_netty_netty_handler() + if not native.existing_rule("io_netty_netty_handler_proxy"): + io_netty_netty_handler_proxy() + if not native.existing_rule("io_netty_netty_resolver"): + io_netty_netty_resolver() + if not native.existing_rule("io_netty_netty_tcnative_boringssl_static"): + io_netty_netty_tcnative_boringssl_static() + if not native.existing_rule("io_netty_netty_transport"): + io_netty_netty_transport() + if not native.existing_rule("io_netty_netty_transport_native_epoll"): + io_netty_netty_transport_native_epoll() + if not native.existing_rule("io_opencensus_opencensus_api"): + io_opencensus_opencensus_api() + if not native.existing_rule("io_opencensus_opencensus_contrib_grpc_metrics"): + 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 omit_org_apache_commons_lang3: - org_apache_commons_lang3() - if not omit_org_codehaus_mojo_animal_sniffer_annotations: + if not native.existing_rule("org_apache_commons_commons_lang3"): + org_apache_commons_commons_lang3() + if not native.existing_rule("org_codehaus_mojo_animal_sniffer_annotations"): org_codehaus_mojo_animal_sniffer_annotations() native.bind( @@ -170,7 +132,7 @@ def com_google_android_annotations(): licenses = ["notice"], # Apache 2.0 ) -def com_google_api_grpc_google_common_protos(): +def com_google_api_grpc_proto_google_common_protos(): jvm_maven_import_external( name = "com_google_api_grpc_proto_google_common_protos", artifact = "com.google.api.grpc:proto-google-common-protos:1.17.0", @@ -206,7 +168,7 @@ def com_google_code_findbugs_jsr305(): licenses = ["notice"], # Apache 2.0 ) -def com_google_code_gson(): +def com_google_code_gson_gson(): jvm_maven_import_external( name = "com_google_code_gson_gson", artifact = "com.google.code.gson:gson:jar:2.8.6", @@ -224,7 +186,7 @@ def com_google_errorprone_error_prone_annotations(): licenses = ["notice"], # Apache 2.0 ) -def com_google_guava(): +def com_google_guava_guava(): jvm_maven_import_external( name = "com_google_guava_guava", artifact = "com.google.guava:guava:28.1-android", @@ -281,7 +243,7 @@ def com_google_truth_truth(): licenses = ["notice"], # Apache 2.0 ) -def com_squareup_okhttp(): +def com_squareup_okhttp_okhttp(): jvm_maven_import_external( name = "com_squareup_okhttp_okhttp", artifact = "com.squareup.okhttp:okhttp:2.5.0", @@ -290,7 +252,7 @@ def com_squareup_okhttp(): licenses = ["notice"], # Apache 2.0 ) -def com_squareup_okio(): +def com_squareup_okio_okio(): jvm_maven_import_external( name = "com_squareup_okio_okio", artifact = "com.squareup.okio:okio:1.13.0", @@ -307,7 +269,7 @@ def io_grpc_grpc_proto(): urls = ["https://github.com/grpc/grpc-proto/archive/435d723289d348e1bc420d420b364369d565182a.zip"], ) -def io_netty_buffer(): +def io_netty_netty_buffer(): jvm_maven_import_external( name = "io_netty_netty_buffer", artifact = "io.netty:netty-buffer:4.1.42.Final", @@ -316,7 +278,7 @@ def io_netty_buffer(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_codec(): +def io_netty_netty_codec(): jvm_maven_import_external( name = "io_netty_netty_codec", artifact = "io.netty:netty-codec:4.1.42.Final", @@ -325,7 +287,7 @@ def io_netty_codec(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_codec_http(): +def io_netty_netty_codec_http(): jvm_maven_import_external( name = "io_netty_netty_codec_http", artifact = "io.netty:netty-codec-http:4.1.42.Final", @@ -334,7 +296,7 @@ def io_netty_codec_http(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_codec_http2(): +def io_netty_netty_codec_http2(): jvm_maven_import_external( name = "io_netty_netty_codec_http2", artifact = "io.netty:netty-codec-http2:4.1.42.Final", @@ -343,7 +305,7 @@ def io_netty_codec_http2(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_codec_socks(): +def io_netty_netty_codec_socks(): jvm_maven_import_external( name = "io_netty_netty_codec_socks", artifact = "io.netty:netty-codec-socks:4.1.42.Final", @@ -352,7 +314,7 @@ def io_netty_codec_socks(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_common(): +def io_netty_netty_common(): jvm_maven_import_external( name = "io_netty_netty_common", artifact = "io.netty:netty-common:4.1.42.Final", @@ -361,7 +323,7 @@ def io_netty_common(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_handler(): +def io_netty_netty_handler(): jvm_maven_import_external( name = "io_netty_netty_handler", artifact = "io.netty:netty-handler:4.1.42.Final", @@ -370,7 +332,7 @@ def io_netty_handler(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_handler_proxy(): +def io_netty_netty_handler_proxy(): jvm_maven_import_external( name = "io_netty_netty_handler_proxy", artifact = "io.netty:netty-handler-proxy:4.1.42.Final", @@ -379,7 +341,7 @@ def io_netty_handler_proxy(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_resolver(): +def io_netty_netty_resolver(): jvm_maven_import_external( name = "io_netty_netty_resolver", artifact = "io.netty:netty-resolver:4.1.42.Final", @@ -388,7 +350,7 @@ def io_netty_resolver(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_tcnative_boringssl_static(): +def io_netty_netty_tcnative_boringssl_static(): jvm_maven_import_external( name = "io_netty_netty_tcnative_boringssl_static", artifact = "io.netty:netty-tcnative-boringssl-static:2.0.26.Final", @@ -397,7 +359,7 @@ def io_netty_tcnative_boringssl_static(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_transport(): +def io_netty_netty_transport(): jvm_maven_import_external( name = "io_netty_netty_transport", artifact = "io.netty:netty-transport:4.1.42.Final", @@ -406,7 +368,7 @@ def io_netty_transport(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_transport_native_epoll(): +def io_netty_netty_transport_native_epoll(): jvm_maven_import_external( name = "io_netty_netty_transport_native_epoll", artifact = "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final", @@ -415,7 +377,7 @@ def io_netty_transport_native_epoll(): licenses = ["notice"], # Apache 2.0 ) -def io_opencensus_api(): +def io_opencensus_opencensus_api(): jvm_maven_import_external( name = "io_opencensus_opencensus_api", artifact = "io.opencensus:opencensus-api:0.24.0", @@ -424,7 +386,7 @@ def io_opencensus_api(): licenses = ["notice"], # Apache 2.0 ) -def io_opencensus_grpc_metrics(): +def io_opencensus_opencensus_contrib_grpc_metrics(): jvm_maven_import_external( name = "io_opencensus_opencensus_contrib_grpc_metrics", artifact = "io.opencensus:opencensus-contrib-grpc-metrics:0.24.0", @@ -433,7 +395,7 @@ def io_opencensus_grpc_metrics(): licenses = ["notice"], # Apache 2.0 ) -def io_perfmark(): +def io_perfmark_perfmark_api(): jvm_maven_import_external( name = "io_perfmark_perfmark_api", artifact = "io.perfmark:perfmark-api:0.19.0", @@ -442,7 +404,7 @@ def io_perfmark(): licenses = ["notice"], # Apache 2.0 ) -def javax_annotation(): +def javax_annotation_javax_annotation_api(): # Use //stub:javax_annotation for neverlink=1 support. jvm_maven_import_external( name = "javax_annotation_javax_annotation_api", @@ -461,7 +423,7 @@ def junit_junit(): licenses = ["notice"], # EPL 1.0 ) -def org_apache_commons_lang3(): +def org_apache_commons_commons_lang3(): jvm_maven_import_external( name = "org_apache_commons_commons_lang3", artifact = "org.apache.commons:commons-lang3:3.5", From 72bbfcb39a203114af20ca60b68e130867b1b365 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 18 Dec 2019 14:35:43 -0800 Subject: [PATCH 2/3] examples: Suggest Bazel's http_repository instead of git_repository http_repository is preferred by Bazel over git_repository. --- examples/WORKSPACE | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 8e358de2a33..003e3c9fce3 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -1,10 +1,11 @@ workspace(name = "examples") -# For released versions, use the tagged git-repository: -# git_repository( +# For released versions, use release tag: +# http_repository( # name = "io_grpc_grpc_java", -# remote = "https://github.com/grpc/grpc-java.git", -# tag = "", +# sha256 = "", +# strip_prefix = "grpc-java-", +# url = "https://github.com/grpc/grpc-java/archive/.zip", # ) local_repository( name = "io_grpc_grpc_java", From a7c38a2869071f39b94da1bf2eb74df08e62ff48 Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Wed, 18 Dec 2019 14:51:08 -0800 Subject: [PATCH 3/3] bazel: Support maven_install maven_install is strongly superior to previous forms of grabbing dependencies from Maven as it computes the appropriate versions to use from the full transitive dependencies of all libraries used by an application. It also has much less boilerplate and includes dependencies with generated targets. In the future we will drop the jvm_maven_import_external usages and require maven_install, at which point we can swap to using the `@maven' repository and no longer depend on compat_repositories. Fixes #5359 --- WORKSPACE | 27 ++++++++++++ buildscripts/kokoro/bazel.sh | 2 +- examples/BUILD.bazel | 8 ++-- examples/WORKSPACE | 38 ++++++++++++----- examples/example-gauth/BUILD.bazel | 6 +-- examples/example-tls/BUILD.bazel | 4 +- netty/shaded/BUILD.bazel | 2 +- protobuf/BUILD.bazel | 1 - repositories.bzl | 66 +++++++++++++++++++++++++----- 9 files changed, 121 insertions(+), 33 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index a347e1233f1..dad4842a7a7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -1,8 +1,35 @@ workspace(name = "io_grpc_grpc_java") +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "rules_jvm_external", + sha256 = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a", + strip_prefix = "rules_jvm_external-3.0", + url = "https://github.com/bazelbuild/rules_jvm_external/archive/3.0.zip", +) + +load("@rules_jvm_external//:defs.bzl", "maven_install") +load("//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS") +load("//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS") + +maven_install( + artifacts = IO_GRPC_GRPC_JAVA_ARTIFACTS, + generate_compat_repositories = True, + override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS, + repositories = [ + "https://repo.maven.apache.org/maven2/", + ], +) + +load("@maven//:compat.bzl", "compat_repositories") + +compat_repositories() + load("//:repositories.bzl", "grpc_java_repositories") grpc_java_repositories() load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + protobuf_deps() diff --git a/buildscripts/kokoro/bazel.sh b/buildscripts/kokoro/bazel.sh index ec9f4486ecb..f63c05f300b 100755 --- a/buildscripts/kokoro/bazel.sh +++ b/buildscripts/kokoro/bazel.sh @@ -3,7 +3,7 @@ set -exu -o pipefail cat /VERSION -use_bazel.sh 0.28.1 +use_bazel.sh 1.0.1 bazel version cd github/grpc-java diff --git a/examples/BUILD.bazel b/examples/BUILD.bazel index db8916d700b..e7f00381ad1 100644 --- a/examples/BUILD.bazel +++ b/examples/BUILD.bazel @@ -70,15 +70,15 @@ java_library( ":helloworld_java_proto", ":route_guide_java_grpc", ":route_guide_java_proto", - "@com_google_api_grpc_proto_google_common_protos//jar", - "@com_google_code_findbugs_jsr305//jar", - "@com_google_code_gson_gson", - "@com_google_guava_guava//jar", "@com_google_protobuf//:protobuf_java", "@com_google_protobuf//:protobuf_java_util", "@io_grpc_grpc_java//api", "@io_grpc_grpc_java//protobuf", "@io_grpc_grpc_java//stub", + "@maven//:com_google_api_grpc_proto_google_common_protos", + "@maven//:com_google_code_findbugs_jsr305", + "@maven//:com_google_code_gson_gson", + "@maven//:com_google_guava_guava", ], ) diff --git a/examples/WORKSPACE b/examples/WORKSPACE index 003e3c9fce3..1e5bad7f9f9 100644 --- a/examples/WORKSPACE +++ b/examples/WORKSPACE @@ -12,25 +12,41 @@ local_repository( path = "..", ) -load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories") - - +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -maven_jar( - name = "com_google_api_grpc_cloud_pubsub_v1", - artifact = "com.google.api.grpc:grpc-google-cloud-pubsub-v1:0.1.24", - sha1 = "601d8be0fd0cc0e050b1af3b88f191ada9a2f4e5", +http_archive( + name = "rules_jvm_external", + sha256 = "62133c125bf4109dfd9d2af64830208356ce4ef8b165a6ef15bbff7460b35c3a", + strip_prefix = "rules_jvm_external-3.0", + url = "https://github.com/bazelbuild/rules_jvm_external/archive/3.0.zip", ) -maven_jar( - name = "com_google_api_grpc_proto_cloud_pubsub_v1", - artifact = "com.google.api.grpc:proto-google-cloud-pubsub-v1:0.1.24", - sha1 = "e6dd66635f674b4e380dfd3de252ae019a51a67e", +load("@rules_jvm_external//:defs.bzl", "maven_install") +load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_ARTIFACTS") +load("@io_grpc_grpc_java//:repositories.bzl", "IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS") + +maven_install( + artifacts = [ + "com.google.api.grpc:grpc-google-cloud-pubsub-v1:0.1.24", + "com.google.api.grpc:proto-google-cloud-pubsub-v1:0.1.24", + ] + IO_GRPC_GRPC_JAVA_ARTIFACTS, + generate_compat_repositories = True, + override_targets = IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS, + repositories = [ + "https://repo.maven.apache.org/maven2/", + ], ) +load("@maven//:compat.bzl", "compat_repositories") +compat_repositories() +load("@io_grpc_grpc_java//:repositories.bzl", "grpc_java_repositories") + +# Run grpc_java_repositories after compat_repositories to ensure the +# maven_install-selected dependencies are used. grpc_java_repositories() load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") + protobuf_deps() diff --git a/examples/example-gauth/BUILD.bazel b/examples/example-gauth/BUILD.bazel index e43be5115d4..edc4a291e27 100644 --- a/examples/example-gauth/BUILD.bazel +++ b/examples/example-gauth/BUILD.bazel @@ -7,13 +7,13 @@ java_library( ["src/main/java/**/*.java"], ), deps = [ - "@com_google_api_grpc_cloud_pubsub_v1//jar", - "@com_google_api_grpc_proto_cloud_pubsub_v1//jar", - "@com_google_auth_google_auth_library_oauth2_http//jar", "@io_grpc_grpc_java//api", "@io_grpc_grpc_java//auth", "@io_grpc_grpc_java//protobuf", "@io_grpc_grpc_java//stub", + "@maven//:com_google_api_grpc_grpc_google_cloud_pubsub_v1", + "@maven//:com_google_api_grpc_proto_google_cloud_pubsub_v1", + "@maven//:com_google_auth_google_auth_library_oauth2_http", ], ) diff --git a/examples/example-tls/BUILD.bazel b/examples/example-tls/BUILD.bazel index f75250c235d..3daa305c167 100644 --- a/examples/example-tls/BUILD.bazel +++ b/examples/example-tls/BUILD.bazel @@ -24,7 +24,7 @@ java_library( ["src/main/java/**/*.java"], ), runtime_deps = [ - "@io_netty_netty_tcnative_boringssl_static//jar", + "@maven//:io_netty_netty_tcnative_boringssl_static", ], deps = [ ":helloworld_java_grpc", @@ -33,7 +33,7 @@ java_library( "@io_grpc_grpc_java//netty", "@io_grpc_grpc_java//protobuf", "@io_grpc_grpc_java//stub", - "@io_netty_netty_handler//jar", + "@maven//:io_netty_netty_handler", ], ) diff --git a/netty/shaded/BUILD.bazel b/netty/shaded/BUILD.bazel index 096001c4416..bb23cfdf489 100644 --- a/netty/shaded/BUILD.bazel +++ b/netty/shaded/BUILD.bazel @@ -5,6 +5,6 @@ java_library( runtime_deps = [ "//netty", "@io_netty_netty_tcnative_boringssl_static//jar", - "@io_netty_netty_transport_native_epoll//jar", + "@io_netty_netty_transport_native_epoll_linux_x86_64//jar", ], ) diff --git a/protobuf/BUILD.bazel b/protobuf/BUILD.bazel index d6df923e056..42085eea583 100644 --- a/protobuf/BUILD.bazel +++ b/protobuf/BUILD.bazel @@ -12,6 +12,5 @@ java_library( "@com_google_guava_guava//jar", "@com_google_j2objc_j2objc_annotations//jar", "@com_google_protobuf//:protobuf_java", - "@com_google_protobuf//:protobuf_java_util", ], ) diff --git a/repositories.bzl b/repositories.bzl index e90a8860ddb..dda730dfd57 100644 --- a/repositories.bzl +++ b/repositories.bzl @@ -3,6 +3,48 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") +# For use with maven_install's artifacts. +# maven_install( +# ... +# artifacts = [ +# # Your own deps +# ] + IO_GRPC_GRPC_JAVA_ARTIFACTS, +# ) +IO_GRPC_GRPC_JAVA_ARTIFACTS = [ + "com.google.android:annotations:4.1.1.4", + "com.google.api.grpc:proto-google-common-protos:1.17.0", + "com.google.auth:google-auth-library-credentials:0.19.0", + "com.google.auth:google-auth-library-oauth2-http:0.19.0", + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.code.gson:gson:jar:2.8.6", + "com.google.errorprone:error_prone_annotations:2.3.3", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:guava:28.1-android", + "com.google.j2objc:j2objc-annotations:1.3", + "com.google.truth:truth:1.0", + "com.squareup.okhttp:okhttp:2.5.0", + "com.squareup.okio:okio:1.13.0", + "io.netty:netty-buffer:4.1.42.Final", + "io.netty:netty-codec-http2:4.1.42.Final", + "io.netty:netty-codec-http:4.1.42.Final", + "io.netty:netty-codec-socks:4.1.42.Final", + "io.netty:netty-codec:4.1.42.Final", + "io.netty:netty-common:4.1.42.Final", + "io.netty:netty-handler-proxy:4.1.42.Final", + "io.netty:netty-handler:4.1.42.Final", + "io.netty:netty-resolver:4.1.42.Final", + "io.netty:netty-tcnative-boringssl-static:2.0.26.Final", + "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final", + "io.netty:netty-transport:4.1.42.Final", + "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.codehaus.mojo:animal-sniffer-annotations:1.18", +] + # For use with maven_install's override_targets. # maven_install( # ... @@ -22,6 +64,9 @@ load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") # "your.target:artifact": "@//third_party/artifact", # ) IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = { + "com.google.protobuf:protobuf-java": "@com_google_protobuf//:protobuf_java", + "com.google.protobuf:protobuf-java-util": "@com_google_protobuf//:protobuf_java_util", + "com.google.protobuf:protobuf-javalite": "@com_google_protobuf_javalite//:protobuf_java_lite", "io.grpc:grpc-alts": "@io_grpc_grpc_java//alts", "io.grpc:grpc-api": "@io_grpc_grpc_java//api", "io.grpc:grpc-auth": "@io_grpc_grpc_java//auth", @@ -39,6 +84,13 @@ IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = { def grpc_java_repositories(): """Imports dependencies for grpc-java.""" + if not native.existing_rule("com_google_protobuf"): + com_google_protobuf() + if not native.existing_rule("com_google_protobuf_javalite"): + com_google_protobuf_javalite() + if not native.existing_rule("io_grpc_grpc_proto"): + io_grpc_grpc_proto() + if not native.existing_rule("com_google_android_annotations"): com_google_android_annotations() if not native.existing_rule("com_google_api_grpc_proto_google_common_protos"): @@ -59,14 +111,8 @@ def grpc_java_repositories(): com_google_guava_failureaccess() if not native.existing_rule("com_google_j2objc_j2objc_annotations"): com_google_j2objc_j2objc_annotations() - if not native.existing_rule("com_google_protobuf"): - com_google_protobuf() - if not native.existing_rule("com_google_protobuf_javalite"): - com_google_protobuf_javalite() if not native.existing_rule("com_google_truth_truth"): com_google_truth_truth() - if not native.existing_rule("io_grpc_grpc_proto"): - io_grpc_grpc_proto() if not native.existing_rule("com_squareup_okhttp_okhttp"): com_squareup_okhttp_okhttp() if not native.existing_rule("com_squareup_okio_okio"): @@ -93,8 +139,8 @@ def grpc_java_repositories(): io_netty_netty_tcnative_boringssl_static() if not native.existing_rule("io_netty_netty_transport"): io_netty_netty_transport() - if not native.existing_rule("io_netty_netty_transport_native_epoll"): - io_netty_netty_transport_native_epoll() + if not native.existing_rule("io_netty_netty_transport_native_epoll_linux_x86_64"): + io_netty_netty_transport_native_epoll_linux_x86_64() if not native.existing_rule("io_opencensus_opencensus_api"): io_opencensus_opencensus_api() if not native.existing_rule("io_opencensus_opencensus_contrib_grpc_metrics"): @@ -368,9 +414,9 @@ def io_netty_netty_transport(): licenses = ["notice"], # Apache 2.0 ) -def io_netty_netty_transport_native_epoll(): +def io_netty_netty_transport_native_epoll_linux_x86_64(): jvm_maven_import_external( - name = "io_netty_netty_transport_native_epoll", + name = "io_netty_netty_transport_native_epoll_linux_x86_64", artifact = "io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.42.Final", server_urls = ["https://repo.maven.apache.org/maven2/"], artifact_sha256 = "7bdf3003d5b60b061b494e62d1bafc420caf800efb743b14ec01ceaef1d3fa3e",