Merge pull request #12669: [BEAM-5715, BEAM-8862, BEAM-8702] Cherry-pick #12508

[BEAM-5715, BEAM-8862, BEAM-8702] Removes all references to grpc_all …

…and replaces them with more specific dependencies. Also fixes a few other dependency errors. (#12508)
diff --git a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
index bc819b9..3782b9b 100644
--- a/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
+++ b/buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy
@@ -497,7 +497,8 @@
         google_http_client_protobuf                 : "com.google.http-client:google-http-client-protobuf:$google_http_clients_version",
         google_oauth_client                         : "com.google.oauth-client:google-oauth-client:$google_oauth_clients_version",
         google_oauth_client_java6                   : "com.google.oauth-client:google-oauth-client-java6:$google_oauth_clients_version",
-        grpc_all                                    : "io.grpc:grpc-all:$grpc_version",
+        // Don't use grpc_all, it can cause issues in Bazel builds. Reference the gRPC libraries you need individually instead.
+        grpc_api                                    : "io.grpc:grpc-api:$grpc_version",
         grpc_alts                                   : "io.grpc:grpc-alts:$grpc_version",
         grpc_auth                                   : "io.grpc:grpc-auth:$grpc_version",
         grpc_core                                   : "io.grpc:grpc-core:$grpc_version",
diff --git a/sdks/java/extensions/sql/zetasql/build.gradle b/sdks/java/extensions/sql/zetasql/build.gradle
index 58a0323..2cf39b2 100644
--- a/sdks/java/extensions/sql/zetasql/build.gradle
+++ b/sdks/java/extensions/sql/zetasql/build.gradle
@@ -35,7 +35,7 @@
   compile project(":sdks:java:extensions:sql")
   compile library.java.vendored_calcite_1_20_0
   compile library.java.guava
-  compile library.java.grpc_all
+  compile library.java.grpc_api
   compile library.java.protobuf_java
   compile library.java.protobuf_java_util
   compile "com.google.api.grpc:proto-google-common-protos:1.12.0" // Interfaces with ZetaSQL use this
diff --git a/sdks/java/io/google-cloud-platform/build.gradle b/sdks/java/io/google-cloud-platform/build.gradle
index 175044b..5fb72d7 100644
--- a/sdks/java/io/google-cloud-platform/build.gradle
+++ b/sdks/java/io/google-cloud-platform/build.gradle
@@ -57,7 +57,6 @@
   compile library.java.google_cloud_spanner
   compile library.java.google_http_client
   compile library.java.google_http_client_jackson2
-  compile library.java.grpc_all
   compile library.java.grpc_alts
   compile library.java.grpc_auth
   compile library.java.grpc_core
@@ -69,8 +68,10 @@
   compile library.java.grpc_google_cloud_pubsub_v1
   compile library.java.grpc_google_cloud_pubsublite_v1
   compile library.java.guava
+  compile library.java.hamcrest_core
   compile library.java.jackson_databind
   compile library.java.joda_time
+  compile library.java.junit
   compile library.java.netty_handler
   compile library.java.netty_tcnative_boringssl_static
   compile library.java.proto_google_cloud_bigquery_storage_v1beta1
@@ -89,9 +90,7 @@
   testCompile project(path: ":sdks:java:testing:test-utils", configuration: "testRuntime")
   // For testing Cross-language transforms
   testCompile project(":runners:core-construction-java")
-  testCompile library.java.hamcrest_core
   testCompile library.java.hamcrest_library
-  testCompile library.java.junit
   testCompile library.java.mockito_core
   testCompile library.java.powermock
   testCompile library.java.powermock_mockito
diff --git a/sdks/java/io/xml/build.gradle b/sdks/java/io/xml/build.gradle
index 004b95a..c101786 100644
--- a/sdks/java/io/xml/build.gradle
+++ b/sdks/java/io/xml/build.gradle
@@ -23,12 +23,12 @@
 ext.summary = "IO to read and write XML files."
 
 dependencies {
+  compile library.java.jaxb_api
+  compile library.java.jaxb_impl
   compile library.java.vendored_guava_26_0_jre
   compile project(path: ":sdks:java:core", configuration: "shadow")
   compile library.java.stax2_api
   compile library.java.woodstox_core_asl
-  testCompile library.java.jaxb_api
-  testCompile library.java.jaxb_impl
   testCompile project(path: ":sdks:java:core", configuration: "shadowTest")
   testCompile library.java.junit
   testCompile library.java.hamcrest_core