grpc-java/alts/build.gradle

104 lines
3.5 KiB
Groovy
Raw Normal View History

plugins {
id "java-library"
id "maven-publish"
id "com.github.johnrengelman.shadow"
id "com.google.protobuf"
id "ru.vyarus.animalsniffer"
}
2018-02-16 01:28:00 +08:00
description = "gRPC: ALTS"
dependencies {
api project(':grpc-api')
implementation project(':grpc-auth'),
project(':grpc-core'),
alts,census,gcp-observability: Explicitly set grpc-context as an implementation dependency (#10997) Override google-auth `io.grpc:grpc-context` dependency with our own `project(":grpc-context")`. This fixes the issue with classes depending on `grpc-alts` implementation receiving very (!) old `io.grpc:grpc-context:1.27.2` as a transitive dependency of `com.google.auth`. Projects `grpc-census` `grpc-gcp-observability` are affected in the similar way, except `io.grpc:grpc-context:1.59.1` is pulled as a transitive dependency of `io.opencensus`. ### Before ``` ❯ ./gradlew -q :grpc-xds:dependencyInsight --configuration=compileClasspath --dependency=io.grpc:grpc-context *** Skipping the build of codegen and compilation of proto files because skipCodegen=true * Skipping the build of Android projects because skipAndroid=true io.grpc:grpc-context:1.27.2 Variant compile: | Attribute Name | Provided | Requested | |--------------------------------|----------|--------------| | org.gradle.status | release | | | org.gradle.category | library | library | | org.gradle.libraryelements | jar | classes | | org.gradle.usage | java-api | java-api | | org.gradle.dependency.bundling | | external | | org.gradle.jvm.environment | | standard-jvm | | org.gradle.jvm.version | | 8 | io.grpc:grpc-context:1.27.2 \--- io.opencensus:opencensus-api:0.31.1 +--- com.google.http-client:google-http-client:1.43.3 | +--- com.google.auth:google-auth-library-oauth2-http:1.22.0 | | \--- project :grpc-alts | | \--- compileClasspath | \--- com.google.http-client:google-http-client-gson:1.43.3 | \--- com.google.auth:google-auth-library-oauth2-http:1.22.0 (*) \--- io.opencensus:opencensus-contrib-http-util:0.31.1 \--- com.google.http-client:google-http-client:1.43.3 (*) (*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation. ``` ### After ``` ❯ ./gradlew -q :grpc-xds:dependencyInsight --configuration=compileClasspath --dependency=io.grpc:grpc-context *** Skipping the build of codegen and compilation of proto files because skipCodegen=true * Skipping the build of Android projects because skipAndroid=true project :grpc-context Variant apiElements: | Attribute Name | Provided | Requested | |--------------------------------|----------|--------------| | org.gradle.category | library | library | | org.gradle.dependency.bundling | external | external | | org.gradle.jvm.version | 8 | 8 | | org.gradle.libraryelements | jar | classes | | org.gradle.usage | java-api | java-api | | org.gradle.jvm.environment | | standard-jvm | Selection reasons: - By conflict resolution: between versions 1.63.0-SNAPSHOT and 1.27.2 project :grpc-context \--- project :grpc-alts \--- compileClasspath io.grpc:grpc-context:1.27.2 -> project :grpc-context \--- io.opencensus:opencensus-api:0.31.1 +--- com.google.http-client:google-http-client:1.43.3 | +--- com.google.auth:google-auth-library-oauth2-http:1.22.0 | | \--- project :grpc-alts | | \--- compileClasspath | \--- com.google.http-client:google-http-client-gson:1.43.3 | \--- com.google.auth:google-auth-library-oauth2-http:1.22.0 (*) \--- io.opencensus:opencensus-contrib-http-util:0.31.1 \--- com.google.http-client:google-http-client:1.43.3 (*) (*) - Indicates repeated occurrences of a transitive dependency subtree. Gradle expands transitive dependency subtrees only once per project; repeat occurrences only display the root of the subtree, followed by this annotation. ```
2024-03-12 05:00:12 +08:00
project(":grpc-context"), // Override google-auth dependency with our newer version
project(':grpc-grpclb'),
2018-02-16 01:28:00 +08:00
project(':grpc-protobuf'),
project(':grpc-stub'),
libraries.protobuf.java,
libraries.conscrypt,
libraries.guava.jre, // JRE required by protobuf-java-util from grpclb
libraries.google.auth.oauth2Http
def nettyDependency = implementation project(':grpc-netty')
compileOnly libraries.javax.annotation
shadow configurations.implementation.getDependencies().minus(nettyDependency)
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')
testImplementation project(':grpc-testing'),
testFixtures(project(':grpc-core')),
project(':grpc-inprocess'),
project(':grpc-testing-proto'),
libraries.guava,
libraries.junit,
libraries.mockito.core,
libraries.truth
2020-06-04 04:48:02 +08:00
testImplementation libraries.guava.testlib
testRuntimeOnly libraries.netty.tcnative,
libraries.netty.tcnative.classes
testRuntimeOnly (libraries.netty.transport.epoll) {
artifact {
classifier = "linux-x86_64"
}
}
signature libraries.signature.java
2018-02-16 01:28:00 +08:00
}
configureProtoCompilation()
import net.ltgt.gradle.errorprone.CheckSeverity
[tasks.named("compileJava"), tasks.named("compileTestJava")]*.configure {
// ALTS returns a lot of futures that we mostly don't care about.
options.errorprone.check("FutureReturnValueIgnored", CheckSeverity.OFF)
2018-02-16 01:28:00 +08:00
}
tasks.named("javadoc").configure {
exclude 'io/grpc/alts/internal/**'
exclude 'io/grpc/alts/Internal*'
}
tasks.named("jar").configure {
2022-01-19 02:18:16 +08:00
// Must use a different archiveClassifier to avoid conflicting with shadowJar
archiveClassifier = 'original'
manifest {
attributes('Automatic-Module-Name': 'io.grpc.alts')
}
}
// 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.
tasks.named("shadowJar").configure {
2022-01-19 02:18:16 +08:00
archiveClassifier = 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'
}
publishing {
publications {
maven(MavenPublication) {
// We want this to throw an exception if it isn't working
def originalJar = artifacts.find { dep -> dep.classifier == 'original'}
artifacts.remove(originalJar)
pom.withXml {
def dependenciesNode = new Node(null, 'dependencies')
project.configurations.shadow.allDependencies.each { dep ->
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
dependencyNode.appendNode('version', dep.version)
dependencyNode.appendNode('scope', 'compile')
}
asNode().dependencies[0].replaceNode(dependenciesNode)
}
}
}
}