Skip to content

Commit

Permalink
context, all: move Context classes to grpc-api (#10313)
Browse files Browse the repository at this point in the history
* context, all: move Context classes to grpc-api
clean up grpc-context since it has no source code: only add dep on grpc-api
add exclusion for all transitive deps of grpc-api - only guava
exclude grpc-context as a dependency from grpc-alts because all context code is in grpc-api now
api: 1.7 as target Java version for Context source-set of grpc-api

* core, census: fix the issues with android project pulling in old grpc-context version


* api,context: make changes to bazel build files to account for context code moving from context to api
  • Loading branch information
sanjaypujare authored Jun 29, 2023
1 parent d654707 commit 4d2c3aa
Show file tree
Hide file tree
Showing 23 changed files with 40 additions and 39 deletions.
2 changes: 2 additions & 0 deletions api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ java_library(
name = "api",
srcs = glob([
"src/main/java/**/*.java",
"src/context/java/**/*.java",
]),
javacopts = ["-Xep:DoNotCall:OFF"], # Remove once requiring Bazel 3.4.0+; allows non-final
visibility = ["//visibility:public"],
Expand All @@ -13,4 +14,5 @@ java_library(
"@com_google_guava_guava//jar",
"@com_google_j2objc_j2objc_annotations//jar",
],
exports = ["//context"],
)
27 changes: 23 additions & 4 deletions api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,31 @@ plugins {

description = 'gRPC: API'

sourceSets {
context
main {
output.classesDirs.from(sourceSets.context.output.classesDirs)
}
}

compileContextJava {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}


dependencies {
api project(':grpc-context'),
libraries.jsr305,
compileOnly sourceSets.context.output
api libraries.jsr305,
libraries.errorprone.annotations
implementation libraries.guava

testFixturesApi libraries.truth
testFixturesImplementation libraries.jsr305
testFixturesImplementation libraries.guava,
libraries.junit,
libraries.mockito.core
testImplementation testFixtures(project(':grpc-context')),
project(':grpc-testing'),
testImplementation project(':grpc-testing'),
project(':grpc-grpclb')
testImplementation libraries.guava.testlib
jmh project(':grpc-core')
Expand All @@ -29,9 +43,14 @@ dependencies {
}

tasks.named("javadoc").configure {
source sourceSets.context.allSource
// We want io.grpc.Internal, but not io.grpc.Internal*
exclude 'io/grpc/Internal?*.java'
}

tasks.named("sourcesJar").configure {
from sourceSets.context.allSource
}

components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion census/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ description = 'gRPC: Census'

dependencies {
api project(':grpc-api')
// force dependent jars to depend on latest grpc-context
runtimeOnly project(":grpc-context")
implementation libraries.guava,
libraries.opencensus.api,
libraries.opencensus.contrib.grpc.metrics

testImplementation testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-context')),
testFixtures(project(':grpc-core')),
project(':grpc-testing'),
libraries.opencensus.impl
Expand Down
3 changes: 0 additions & 3 deletions context/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
java_library(
name = "context",
srcs = glob([
"src/main/java/**/*.java",
]),
visibility = ["//visibility:public"],
)
29 changes: 6 additions & 23 deletions context/build.gradle
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
plugins {
id "java"
id "java-test-fixtures"
id "java-library"
id "maven-publish"

id "me.champeau.gradle.japicmp"
id "me.champeau.jmh"
id "ru.vyarus.animalsniffer"
}

description = 'gRPC: Context'

sourceCompatibility = 1.7
targetCompatibility = 1.7

dependencies {
testFixturesApi libraries.truth
// Explicitly choose the guava version to stay Java 7-compatible.
testFixturesImplementation 'com.google.guava:guava:30.1.1-android'
testFixturesImplementation libraries.jsr305
testImplementation libraries.jsr305
// Explicitly choose the guava version to stay Java 7-compatible. The rest of gRPC can move
// forward to Java 8-requiring versions. This is also only used for testing, so is unlikely to
// cause problems.
testImplementation 'com.google.guava:guava-testlib:30.1.1-android'
signature "org.codehaus.mojo.signature:java17:1.0@signature"
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
runtimeOnly (project(":grpc-api")) {
exclude group: "com.google.guava", module: "guava"
exclude group: "com.google.code.findbugs", module: "jsr305"
exclude group: "com.google.errorprone", module: "error_prone_annotations"
}
}

components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
5 changes: 3 additions & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ description = 'gRPC: Core'

dependencies {
api project(':grpc-api')
// force dependent jars to depend on latest grpc-context
runtimeOnly project(":grpc-context")
implementation libraries.gson,
libraries.android.annotations,
libraries.animalsniffer.annotations,
Expand All @@ -33,8 +35,7 @@ dependencies {
libraries.mockito.core,
libraries.truth,
project(':grpc-testing')
testImplementation testFixtures(project(':grpc-context')),
testFixtures(project(':grpc-api')),
testImplementation testFixtures(project(':grpc-api')),
project(':grpc-testing'),
project(':grpc-grpclb')
testImplementation libraries.guava.testlib
Expand Down
2 changes: 1 addition & 1 deletion gcp-observability/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ dependencies {
libraries.checker.qual, // Explicit dependency to keep in step with version used by guava
libraries.j2objc.annotations // Explicit dependency to keep in step with version used by guava

testImplementation testFixtures(project(':grpc-context')),
testImplementation testFixtures(project(':grpc-api')),
project(':grpc-testing'),
project(':grpc-testing-proto')
testImplementation (libraries.guava.testlib) {
Expand Down
3 changes: 1 addition & 2 deletions interop-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ dependencies {
libraries.netty.tcnative.classes,
project(':grpc-grpclb'),
project(':grpc-rls')
testImplementation testFixtures(project(':grpc-context')),
testFixtures(project(':grpc-api')),
testImplementation testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-core')),
libraries.mockito.core,
libraries.okhttp
Expand Down
3 changes: 1 addition & 2 deletions istio-interop-testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ dependencies {

runtimeOnly libraries.netty.tcnative,
libraries.netty.tcnative.classes
testImplementation testFixtures(project(':grpc-context')),
testFixtures(project(':grpc-api')),
testImplementation testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-core')),
libraries.mockito.core,
libraries.junit,
Expand Down
2 changes: 1 addition & 1 deletion testing/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ dependencies {
libraries.junit
// Only io.grpc.internal.testing.StatsTestUtils depends on opencensus_api, for internal use.
compileOnly libraries.opencensus.api
runtimeOnly project(":grpc-context") // Pull in newer version than census-api
runtimeOnly project(":grpc-api") // Pull in newer version than census-api

testImplementation libraries.mockito.core

Expand Down

0 comments on commit 4d2c3aa

Please sign in to comment.