Skip to content

Commit

Permalink
Upgade grpc version, use bom instead of manually specifying each time
Browse files Browse the repository at this point in the history
Dependencies are distributed to where they are used now, and
now-unnecessary proto/build.gradle is removed entirely.

Partial deephaven#1270
  • Loading branch information
niloc132 committed Dec 21, 2021
1 parent 60d3c88 commit 16c4177
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 129 deletions.
8 changes: 8 additions & 0 deletions buildSrc/src/main/groovy/Classpaths.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class Classpaths {
static final String GROOVY_GROUP = 'org.codehaus.groovy'
static final String GROOVY_VERSION = '3.0.9'

static final String GRPC_GROUP = 'io.grpc'
static final String GRPC_VERSION = '1.42.0'

static boolean addDependency(Configuration conf, String group, String name, String version, Action<? super DefaultExternalModuleDependency> configure = Actions.doNothing()) {
if (!conf.dependencies.find { it.name == name && it.group == group}) {
DefaultExternalModuleDependency dep = dependency group, name, version
Expand Down Expand Up @@ -195,4 +198,9 @@ class Classpaths {
Configuration config = p.configurations.getByName(configName)
addDependency(config, GROOVY_GROUP, name, GROOVY_VERSION)
}

static void inheritGrpcPlatform(Project p, String configName = JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME) {
Configuration config = p.configurations.getByName(configName)
addDependency(config, p.getDependencies().platform(GRPC_GROUP + ":" + 'grpc-bom' + ":" + GRPC_VERSION))
}
}
5 changes: 5 additions & 0 deletions grpc-api/grpc-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ dependencies {
runtimeOnly project(':extensions-suanshu')
}

Classpaths.inheritGrpcPlatform(project, 'implementation')
implementation "io.grpc:grpc-services"

testImplementation "io.grpc:grpc-testing"

testImplementation TestTools.projectDependency(project, 'engine-table'),
TestTools.projectDependency(project, 'Util')

Expand Down
3 changes: 3 additions & 0 deletions java-client/session-dagger/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ description = 'The Deephaven client session dagger library'
dependencies {
api project(':java-client-session')

Classpaths.inheritGrpcPlatform(project, 'implementation')
implementation 'io.grpc:grpc-api'

Classpaths.inheritDagger(project)

Classpaths.inheritSlf4j(project, 'slf4j-api', 'implementation')
Expand Down
3 changes: 3 additions & 0 deletions java-client/session-examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ dependencies {

implementation 'info.picocli:picocli:4.6.1'

Classpaths.inheritGrpcPlatform(project, 'implementation')
implementation 'io.grpc:grpc-core'

Classpaths.inheritJUnitPlatform(project)
Classpaths.inheritAssertJ(project)
testImplementation 'org.junit.jupiter:junit-jupiter'
Expand Down
4 changes: 4 additions & 0 deletions java-client/session/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ dependencies {
api project(':proto:proto-backplane-grpc')
api project(':uri')

Classpaths.inheritGrpcPlatform(project, 'implementation')
implementation "io.grpc:grpc-stub"

Classpaths.inheritImmutables(project)

compileOnly 'javax.inject:javax.inject:1'
Expand All @@ -19,6 +22,7 @@ dependencies {
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
testImplementation 'junit:junit:4.13.2'
testImplementation 'io.grpc:grpc-testing'

Classpaths.inheritAssertJ(project)

Expand Down
124 changes: 0 additions & 124 deletions proto/build.gradle

This file was deleted.

35 changes: 30 additions & 5 deletions proto/proto-backplane-grpc/build.gradle
Original file line number Diff line number Diff line change
@@ -1,23 +1,48 @@
plugins {
id 'com.bmuschko.docker-remote-api'
id 'java-library'
}

evaluationDependsOn Docker.registryProject('protoc-base')

description = 'The Deephaven proto-backplane-grpc'

configurations.create('download')
configurations.download.transitive=false
configurations {
download {
transitive = false
}

// automatically pick up the standard junit version
testCompile.extendsFrom junit
}

// TODO(deephaven-core#1685): Create strategy around updating and maintaining protoc version
def protobufVersion = '3.17.3'
def boringSslVersion = '2.0.34.Final'

dependencies {
// This should be implementation, if listed at all, at least once we have own own version management
api "com.google.protobuf:protobuf-java:${protobufVersion}"

Classpaths.inheritGrpcPlatform(project, 'implementation')
implementation "io.grpc:grpc-protobuf"
implementation "io.grpc:grpc-api"
implementation "io.grpc:grpc-stub"

runtimeOnly "io.netty:netty-tcnative-boringssl-static:${boringSslVersion}"

// This is excessive, and brings in every grpc jar, making it compile-only limits what it pulls in to
// downstream classpaths
Classpaths.inheritArrow(project, 'flight-core', 'compileOnly')

compileOnly 'javax.inject:javax.inject:1'
compileOnly "javax.annotation:javax.annotation-api:1.3.1"

// technically we should have a runtime dependency on barrage-core, but instead we are regenerating
// the same output that it contains, and we have declared the correct dependencies as necessary
// compile 'io.deephaven.barrage:barrage-core:0.2.0'
download 'io.deephaven.barrage:barrage-core:0.2.0'
Classpaths.inheritArrow(project, 'flight-core', 'download')
Classpaths.inheritArrow(project, 'flight-core', 'compileOnly')

compileOnly 'javax.inject:javax.inject:1'
}

TaskProvider<Task> generateProtobuf = Docker.registerDockerTask(project, 'generateProtobuf') {
Expand Down

0 comments on commit 16c4177

Please sign in to comment.