Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 1 addition & 39 deletions core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,16 @@ java_library(
exports = ["//api"],
)

java_library(
name = "inprocess",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a forwarding library in place. Keep name and visibility and have it export //inprocess. Ditto for util.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

srcs = glob([
"src/main/java/io/grpc/inprocess/*.java",
]),
visibility = ["//visibility:public"],
deps = [
":internal",
"//api",
"//context",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
],
)

java_library(
name = "internal",
visibility = ["//visibility:public"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

internal should not be public. Why did you need this? It was already allowing subpackages.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

srcs = glob([
"src/main/java/io/grpc/internal/*.java",
]),
javacopts = ["-Xep:DoNotCall:OFF"], # Remove once requiring Bazel 3.4.0+; allows non-final
resources = glob([
"src/bazel-internal/resources/**",
]),
visibility = ["//:__subpackages__"],
deps = [
"//api",
"//context",
Expand All @@ -45,35 +28,14 @@ java_library(
],
)

java_library(
name = "util",
srcs = glob([
"src/main/java/io/grpc/util/*.java",
]),
resources = glob([
"src/bazel-util/resources/**",
]),
visibility = ["//visibility:public"],
deps = [
":internal",
"//api",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
"@org_codehaus_mojo_animal_sniffer_annotations//jar",
],
)

# Mirrors the dependencies included in the artifact on Maven Central for usage
# with maven_install's override_targets. Should only be used as a dep for
# pre-compiled binaries on Maven Central.
java_library(
name = "core_maven",
visibility = ["//visibility:public"],
exports = [
":inprocess",
":internal",
":util",
"//api",
],
)
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
io.grpc.internal.PickFirstLoadBalancerProvider
io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RR moving to grpc-util could definitely break users in a hard-to-diagnose way. I'm not sure how we want to handle this. Short-term we could have a runtimeDependency in grpc-core onto grpc-util.

That would mean we'd also want //inprocess in core_maven

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... Short-term we could have a runtimeDependency in grpc-core onto grpc-util.

Interesting. grpc-util has an api dependency on grpc-core so doing what you suggest makes the dependency circular (even with runtimeOnly dependency). Any ideas?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is a blocker and needs to be resolved. So I'll wait for that before I address the remaining comments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was aware that would be the case. But it should work. Are you saying it doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had tried it before I added the comment:

* What went wrong:
Circular dependency between the following tasks:
:grpc-core:checkUpperBoundDeps
+--- :grpc-core:jar
|    +--- :grpc-core:classes
|    |    \--- :grpc-core:compileJava
|    |         \--- :grpc-core:checkUpperBoundDeps (*)
|    \--- :grpc-core:compileJava (*)
\--- :grpc-util:jar
     +--- :grpc-util:classes
     |    \--- :grpc-util:compileJava
     |         +--- :grpc-core:compileJava (*)
     |         \--- :grpc-util:checkUpperBoundDeps
     |              +--- :grpc-core:jar (*)
     |              \--- :grpc-util:jar (*)
     \--- :grpc-util:compileJava (*)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been resolved

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi i just wanted to let you know that this did indeed break for us in a hard to diagnose way. Is there a correct way to upgrade this library so that it does not break? in general we use something like

ManagedChannelBuilder
            .forTarget(URL)
            .defaultLoadBalancingPolicy("round_robin")
            .usePlaintext()
            .build()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mdering "break" is not a helpful description. Please open a new issue and describe the error/problem you see when upgrading. You can link to this PR. For this specific change, it's also important whether you are shading/shadowing/making a fat jar.

io.grpc.util.OutlierDetectionLoadBalancerProvider
2 changes: 1 addition & 1 deletion grpclb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ java_library(
"//api",
"//context",
"//core:internal",
"//core:util",
"//util",
"//stub",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
Expand Down
2 changes: 1 addition & 1 deletion grpclb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
description = "gRPC: GRPCLB LoadBalancer plugin"

dependencies {
implementation project(':grpc-core'),
implementation project(':grpc-inprocess'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was it changed to depend on inprocess?

project(':grpc-protobuf'),
project(':grpc-stub'),
libraries.protobuf.java,
Expand Down
16 changes: 16 additions & 0 deletions inprocess/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
java_library(
name = "inprocess",
srcs = glob([
"src/main/java/io/grpc/inprocess/*.java",
]),
visibility = ["//visibility:public"],
deps = [
"//core:internal",
"//api",
"//context",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
],
)
65 changes: 65 additions & 0 deletions inprocess/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
plugins {
id "java-library"
id "java-test-fixtures"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete. There are no test fixtures here.

id "maven-publish"

id "me.champeau.jmh"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted but not deleting for util (since util has jmh)

id "ru.vyarus.animalsniffer"
}

import static java.nio.charset.StandardCharsets.US_ASCII;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete both imports.


import com.google.common.primitives.Bytes;

description = 'gRPC: Inprocess'

dependencies {
api project(':grpc-core')
// force dependent jars to depend on latest grpc-context
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this. It was only for core.

runtimeOnly project(":grpc-context")
implementation libraries.gson,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete all these deps except guava.

libraries.android.annotations,
libraries.animalsniffer.annotations,
libraries.errorprone.annotations,
libraries.guava,
libraries.perfmark.api
testFixturesApi libraries.junit
testFixturesImplementation libraries.guava,
libraries.mockito.core,
libraries.truth,
project(':grpc-testing')
testImplementation testFixtures(project(':grpc-api')),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete grpc-api fixture

project(':grpc-testing'),
project(':grpc-grpclb'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.

testFixtures(project(':grpc-core'))
testImplementation libraries.guava.testlib

testRuntimeOnly project(':grpc-census')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete.


jmh project(':grpc-testing')

signature libraries.signature.java
signature libraries.signature.android
}

tasks.named("javadoc").configure {
exclude 'io/grpc/inprocess/Internal*'
}

animalsniffer {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete. There's no jmh.

// Don't check sourceSets.jmh
sourceSets = [
sourceSets.main,
sourceSets.test
]
}

components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Delete both lines

components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }


tasks.register("versionFile") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep this in core. It is not needed in inprocess and util.

doLast {
new File(buildDir, "version").write("${project.version}\n")
}
}
2 changes: 1 addition & 1 deletion okhttp/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ java_library(
deps = [
"//api",
"//core:internal",
"//core:util",
"//util",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_errorprone_error_prone_annotations//jar",
"@com_google_guava_guava//jar",
Expand Down
2 changes: 1 addition & 1 deletion okhttp/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
description = "gRPC: OkHttp"

dependencies {
api project(':grpc-core')
api project(':grpc-util')
implementation libraries.okio,
libraries.guava,
libraries.perfmark.api
Expand Down
2 changes: 2 additions & 0 deletions repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ IO_GRPC_GRPC_JAVA_OVERRIDE_TARGETS = {
"io.grpc:grpc-stub": "@io_grpc_grpc_java//stub",
"io.grpc:grpc-testing": "@io_grpc_grpc_java//testing",
"io.grpc:grpc-xds": "@io_grpc_grpc_java//xds:xds_maven",
"io.grpc:grpc-inprocess": "@io_grpc_grpc_java//inprocess",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sort these.

"io.grpc:grpc-util": "@io_grpc_grpc_java//util",
}

def grpc_java_repositories():
Expand Down
2 changes: 1 addition & 1 deletion rls/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ java_library(
"//api",
"//core",
"//core:internal",
"//core:util",
"//util",
"//stub",
"@com_google_auto_value_auto_value_annotations//jar",
"@com_google_code_findbugs_jsr305//jar",
Expand Down
6 changes: 3 additions & 3 deletions rls/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id "java"
id "java-library"
id "maven-publish"
id "com.google.protobuf"
id "jacoco"
Expand All @@ -9,8 +9,8 @@ plugins {
description = "gRPC: RouteLookupService Loadbalancing plugin"

dependencies {
implementation project(':grpc-core'),
project(':grpc-protobuf'),
api project(':grpc-util')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an implementation dependency.

implementation project(':grpc-protobuf'),
project(':grpc-stub'),
libraries.auto.value.annotations,
libraries.guava
Expand Down
2 changes: 1 addition & 1 deletion services/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ java_library(
":_health_java_grpc",
"//api",
"//core:internal",
"//core:util",
"//util",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@io_grpc_grpc_proto//:health_java_proto",
Expand Down
2 changes: 1 addition & 1 deletion services/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tasks.named("compileJava").configure {
dependencies {
api project(':grpc-protobuf'),
project(':grpc-stub'),
project(':grpc-core')
project(':grpc-util')
implementation libraries.protobuf.java.util,
libraries.guava.jre // JRE required by protobuf-java-util

Expand Down
3 changes: 2 additions & 1 deletion servlet/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies {
compileOnly 'javax.servlet:javax.servlet-api:4.0.1',
libraries.javax.annotation // java 9, 10 needs it

implementation project(':grpc-core'),
implementation project(':grpc-util'),
libraries.guava

testImplementation 'javax.servlet:javax.servlet-api:4.0.1',
Expand All @@ -43,6 +43,7 @@ dependencies {
itImplementation project(':grpc-servlet'),
project(':grpc-netty'),
project(':grpc-core').sourceSets.test.runtimeClasspath,
project(':grpc-util').sourceSets.test.runtimeClasspath,
libraries.junit
itImplementation(project(':grpc-interop-testing')) {
// Avoid grpc-netty-shaded dependency
Expand Down
3 changes: 2 additions & 1 deletion servlet/jakarta/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,13 @@ dependencies {
compileOnly 'jakarta.servlet:jakarta.servlet-api:5.0.0',
libraries.javax.annotation

implementation project(':grpc-core'),
implementation project(':grpc-util'),
libraries.guava

itImplementation project(':grpc-servlet-jakarta'),
project(':grpc-netty'),
project(':grpc-core').sourceSets.test.runtimeClasspath,
project(':grpc-util').sourceSets.test.runtimeClasspath,
libraries.junit
itImplementation(project(':grpc-interop-testing')) {
// Avoid grpc-netty-shaded dependency
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ include ":grpc-authz"
include ":grpc-gcp-observability"
include ":grpc-gcp-observability:interop"
include ":grpc-istio-interop-testing"
include ":grpc-inprocess"
include ":grpc-util"

project(':grpc-api').projectDir = "$rootDir/api" as File
project(':grpc-core').projectDir = "$rootDir/core" as File
Expand Down Expand Up @@ -91,6 +93,8 @@ project(':grpc-authz').projectDir = "$rootDir/authz" as File
project(':grpc-gcp-observability').projectDir = "$rootDir/gcp-observability" as File
project(':grpc-gcp-observability:interop').projectDir = "$rootDir/gcp-observability/interop" as File
project(':grpc-istio-interop-testing').projectDir = "$rootDir/istio-interop-testing" as File
project(':grpc-inprocess').projectDir = "$rootDir/inprocess" as File
project(':grpc-util').projectDir = "$rootDir/util" as File

if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) {
println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true'
Expand Down
4 changes: 2 additions & 2 deletions testing/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ java_library(
deps = [
"//api",
"//context",
"//core:inprocess",
"//core:util",
"//inprocess",
"//util",
"//stub",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
Expand Down
3 changes: 2 additions & 1 deletion testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ plugins {
description = "gRPC: Testing"

dependencies {
api project(':grpc-core'),
api project(':grpc-inprocess'),
project(':grpc-util'),
project(':grpc-stub'),
libraries.junit
// Only io.grpc.internal.testing.StatsTestUtils depends on opencensus_api, for internal use.
Expand Down
30 changes: 30 additions & 0 deletions util/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
java_library(
name = "util",
srcs = glob([
"src/main/java/io/grpc/util/*.java",
]),
resources = glob([
"src/bazel-util/resources/**",
]),
visibility = ["//visibility:public"],
deps = [
"//api",
"//core:internal",
"@com_google_code_findbugs_jsr305//jar",
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
"@org_codehaus_mojo_animal_sniffer_annotations//jar",
],
)

# Mirrors the dependencies included in the artifact on Maven Central for usage
# with maven_install's override_targets. Should only be used as a dep for
# pre-compiled binaries on Maven Central.
java_library(
name = "util_maven",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to export //api from here, so delete the entire target. If it were needed, it should have been used from repositories.bzl

visibility = ["//visibility:public"],
exports = [
":util",
"//api",
],
)
Loading