diff options
author | Eric Anderson <ejona@google.com> | 2018-08-15 17:39:20 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-15 17:39:20 -0700 |
commit | 3792242ae11ad9a4992ea551629fe108be128d87 (patch) | |
tree | f7f5cc9e6976349c141db124217f32b094087b1e | |
parent | 0d4051ca6ee0c0240d79f88082831c22c26c4844 (diff) | |
download | grpc-grpc-java-3792242ae11ad9a4992ea551629fe108be128d87.tar.gz |
alts: Use grpc-netty-shaded instead of grpc-netty
There's no good way to provide users of ALTS a choice between grpc-netty
and grpc-netty-shaded. Since Netty is not exposed through the ALTS API
surface, we opt for the shaded version as it has fewer deployment
issues. However, this also means that we _can't_ expose any Netty API,
like EventLoopGroup.
-rw-r--r-- | alts/build.gradle | 40 | ||||
-rw-r--r-- | examples/build.gradle | 3 | ||||
-rw-r--r-- | examples/pom.xml | 8 | ||||
-rw-r--r-- | netty/shaded/build.gradle | 6 |
4 files changed, 56 insertions, 1 deletions
diff --git a/alts/build.gradle b/alts/build.gradle index c950edffe..55ba1c4cf 100644 --- a/alts/build.gradle +++ b/alts/build.gradle @@ -1,3 +1,10 @@ +buildscript { + repositories { jcenter() } + dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4' } +} + +apply plugin: 'com.github.johnrengelman.shadow' + description = "gRPC: ALTS" sourceCompatibility = 1.7 @@ -39,3 +46,36 @@ configureProtoCompilation() } javadoc { exclude 'io/grpc/alts/internal/**' } + +artifacts { + archives shadowJar +} + +jar { + // Must use a different classifier to avoid conflicting with shadowJar + classifier = 'original' +} +configurations.archives.artifacts.removeAll { it.classifier == "original" } + +// We want to use grpc-netty-shaded instead of grpc-netty. But we also want our +// source to work with Bazel, so we rewrite the code as part of the build. +shadowJar { + classifier = null + dependencies { + exclude(dependency {true}) + } + relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty' + relocate 'io.netty', 'io.grpc.netty.shaded.io.netty' +} + +[ + install.repositories.mavenInstaller, + uploadArchives.repositories.mavenDeployer, +]*.pom*.whenConfigured { pom -> + def netty = pom.dependencies.find {dep -> dep.artifactId == 'grpc-netty'} + // Swap our dependency to grpc-netty-shaded. Projects depending on this via + // project(':grpc-alts') will still be using the non-shaded form. + netty.artifactId = "grpc-netty-shaded" + // Depend on specific version of grpc-netty-shaded because it is unstable API + netty.version = "[" + netty.version + "]" +} diff --git a/examples/build.gradle b/examples/build.gradle index 3defa6f9f..b7406d4f7 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -35,7 +35,8 @@ dependencies { compile "io.grpc:grpc-stub:${grpcVersion}" compileOnly "javax.annotation:javax.annotation-api:1.2" - // Used for TLS in HelloWorldServerTls + // Used in HelloWorldServerTls + compile "io.grpc:grpc-netty:${grpcVersion}" compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}" compile "com.google.protobuf:protobuf-java-util:${protobufVersion}" diff --git a/examples/pom.xml b/examples/pom.xml index 38e482990..93911e79a 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -46,11 +46,19 @@ <version>${grpc.version}</version> <scope>test</scope> </dependency> + + <!-- Used in HelloWorldServerTls --> + <dependency> + <groupId>io.grpc</groupId> + <artifactId>grpc-netty</artifactId> + <version>${grpc.version}</version> + </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-tcnative-boringssl-static</artifactId> <version>${netty.tcnative.version}</version> </dependency> + <dependency> <groupId>com.google.api.grpc</groupId> <artifactId>proto-google-common-protos</artifactId> diff --git a/netty/shaded/build.gradle b/netty/shaded/build.gradle index a44ebef81..434b7fb10 100644 --- a/netty/shaded/build.gradle +++ b/netty/shaded/build.gradle @@ -24,6 +24,12 @@ artifacts { // We want uploadArchives to handle the shadowJar; we don't care abo // uploadShadow archives shadowJar } +jar { + // Must use a different classifier to avoid conflicting with shadowJar + classifier = 'original' +} +configurations.archives.artifacts.removeAll { it.classifier == "original" } + shadowJar { classifier = null dependencies { |