mirror of https://github.com/grpc/grpc-java.git
all: introduce gradle util functions to manage guava dependency
Define util function to exclude guava's transitive dependencies jsr305 and animal-sniffer-annotations, and always manually add them as runtimeOnly dependency. error_prone_annotations is an exception: It is also excluded but manually added not as runtimeOnly. It must always compile with guava, otherwise users will see warning spams if guava is in the compile classpath but error_prone_annotations is not.
This commit is contained in:
parent
9520dc4c45
commit
ce9d217920
|
@ -15,12 +15,7 @@ dependencies {
|
||||||
libraries.errorprone,
|
libraries.errorprone,
|
||||||
libraries.jsr305,
|
libraries.jsr305,
|
||||||
libraries.animalsniffer_annotations
|
libraries.animalsniffer_annotations
|
||||||
compile (libraries.guava) {
|
guavaDependency 'compile'
|
||||||
// prefer our own versions from libraries instead of Guava's dependency
|
|
||||||
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile project(':grpc-context').sourceSets.test.output,
|
testCompile project(':grpc-context').sourceSets.test.output,
|
||||||
project(':grpc-testing'),
|
project(':grpc-testing'),
|
||||||
|
|
51
build.gradle
51
build.gradle
|
@ -187,6 +187,57 @@ subprojects {
|
||||||
// Jetty ALPN dependencies
|
// Jetty ALPN dependencies
|
||||||
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.9'
|
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.9'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// A util function to config guava dependency with transitive dependencies
|
||||||
|
// properly resolved for the failOnVersionConflict strategy.
|
||||||
|
guavaDependency = { configurationName ->
|
||||||
|
dependencies."$configurationName"(libraries.guava) {
|
||||||
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
||||||
|
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
||||||
|
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
||||||
|
}
|
||||||
|
dependencies."$configurationName" libraries.errorprone
|
||||||
|
dependencies.runtimeOnly libraries.animalsniffer_annotations
|
||||||
|
dependencies.runtimeOnly libraries.jsr305
|
||||||
|
}
|
||||||
|
|
||||||
|
// A util function to config opencensus_api dependency with transitive
|
||||||
|
// dependencies properly resolved for the failOnVersionConflict strategy.
|
||||||
|
censusApiDependency = { configurationName ->
|
||||||
|
dependencies."$configurationName"(libraries.opencensus_api) {
|
||||||
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
||||||
|
exclude group: 'com.google.guava', module: 'guava'
|
||||||
|
// we'll always be more up-to-date
|
||||||
|
exclude group: 'io.grpc', module: 'grpc-context'
|
||||||
|
}
|
||||||
|
dependencies.runtimeOnly project(':grpc-context')
|
||||||
|
dependencies.runtimeOnly libraries.jsr305
|
||||||
|
guavaDependency 'runtimeOnly'
|
||||||
|
}
|
||||||
|
|
||||||
|
// A util function to config opencensus_contrib_grpc_metrics dependency
|
||||||
|
// with transitive dependencies properly resolved for the failOnVersionConflict
|
||||||
|
// strategy.
|
||||||
|
censusGrpcMetricDependency = { configurationName ->
|
||||||
|
dependencies."$configurationName"(libraries.opencensus_contrib_grpc_metrics) {
|
||||||
|
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
||||||
|
exclude group: 'com.google.guava', module: 'guava'
|
||||||
|
// we'll always be more up-to-date
|
||||||
|
exclude group: 'io.grpc', module: 'grpc-context'
|
||||||
|
}
|
||||||
|
dependencies.runtimeOnly project(':grpc-context')
|
||||||
|
dependencies.runtimeOnly libraries.jsr305
|
||||||
|
guavaDependency 'runtimeOnly'
|
||||||
|
}
|
||||||
|
|
||||||
|
// A util function to config perfmark dependency with transitive
|
||||||
|
// dependencies properly resolved for the failOnVersionConflict strategy.
|
||||||
|
perfmarkDependency = { configurationName ->
|
||||||
|
dependencies."$configurationName"(libraries.perfmark) {
|
||||||
|
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
||||||
|
}
|
||||||
|
dependencies.runtimeOnly libraries.errorprone
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
|
|
|
@ -10,23 +10,8 @@ evaluationDependsOn(project(':grpc-api').path)
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':grpc-api')
|
compile project(':grpc-api')
|
||||||
|
|
||||||
compile (libraries.opencensus_api) {
|
censusApiDependency 'compile'
|
||||||
// prefer 3.0.2 from libraries instead of 3.0.1
|
censusGrpcMetricDependency 'compile'
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
// prefer 20.0 from libraries instead of 19.0
|
|
||||||
exclude group: 'com.google.guava', module: 'guava'
|
|
||||||
// we'll always be more up-to-date
|
|
||||||
exclude group: 'io.grpc', module: 'grpc-context'
|
|
||||||
}
|
|
||||||
|
|
||||||
compile (libraries.opencensus_contrib_grpc_metrics) {
|
|
||||||
// prefer 3.0.2 from libraries instead of 3.0.1
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
// we'll always be more up-to-date
|
|
||||||
exclude group: 'io.grpc', module: 'grpc-context'
|
|
||||||
// prefer 20.0 from libraries instead of 19.0
|
|
||||||
exclude group: 'com.google.guava', module: 'guava'
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile project(':grpc-api').sourceSets.test.output,
|
testCompile project(':grpc-api').sourceSets.test.output,
|
||||||
project(':grpc-context').sourceSets.test.output,
|
project(':grpc-context').sourceSets.test.output,
|
||||||
|
|
|
@ -17,10 +17,7 @@ dependencies {
|
||||||
libraries.gson,
|
libraries.gson,
|
||||||
libraries.android_annotations,
|
libraries.android_annotations,
|
||||||
libraries.errorprone // prefer our version to perfmark's 2.3.3
|
libraries.errorprone // prefer our version to perfmark's 2.3.3
|
||||||
compile (libraries.perfmark) {
|
perfmarkDependency 'compile'
|
||||||
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile project(':grpc-context').sourceSets.test.output,
|
testCompile project(':grpc-context').sourceSets.test.output,
|
||||||
project(':grpc-api').sourceSets.test.output,
|
project(':grpc-api').sourceSets.test.output,
|
||||||
project(':grpc-testing'),
|
project(':grpc-testing'),
|
||||||
|
|
|
@ -12,12 +12,7 @@ description = 'gRPC: Protobuf Lite'
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':grpc-api'),
|
compile project(':grpc-api'),
|
||||||
libraries.protobuf_lite
|
libraries.protobuf_lite
|
||||||
compile (libraries.guava) {
|
guavaDependency 'compile'
|
||||||
// prefer our own versions from libraries instead of Guava's dependency
|
|
||||||
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile project(':grpc-core')
|
testCompile project(':grpc-core')
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,7 @@ description = 'gRPC: Protobuf'
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':grpc-api'),
|
compile project(':grpc-api'),
|
||||||
libraries.protobuf
|
libraries.protobuf
|
||||||
compile (libraries.guava) {
|
guavaDependency 'compile'
|
||||||
// prefer our own versions from libraries instead of Guava's dependency
|
|
||||||
exclude group: 'com.google.errorprone', module: 'error_prone_annotations'
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations'
|
|
||||||
}
|
|
||||||
|
|
||||||
compile (libraries.google_api_protos) {
|
compile (libraries.google_api_protos) {
|
||||||
// 'com.google.api:api-common' transitively depends on auto-value, which breaks our
|
// 'com.google.api:api-common' transitively depends on auto-value, which breaks our
|
||||||
|
|
|
@ -14,14 +14,7 @@ dependencies {
|
||||||
project(':grpc-stub'),
|
project(':grpc-stub'),
|
||||||
libraries.junit
|
libraries.junit
|
||||||
|
|
||||||
compile (libraries.opencensus_api) {
|
censusApiDependency 'compile'
|
||||||
// prefer 3.0.2 from libraries instead of 3.0.1
|
|
||||||
exclude group: 'com.google.code.findbugs', module: 'jsr305'
|
|
||||||
// prefer 20.0 from libraries instead of 19.0
|
|
||||||
exclude group: 'com.google.guava', module: 'guava'
|
|
||||||
// we'll always be more up-to-date
|
|
||||||
exclude group: 'io.grpc', module: 'grpc-context'
|
|
||||||
}
|
|
||||||
|
|
||||||
testCompile (libraries.mockito) {
|
testCompile (libraries.mockito) {
|
||||||
// prefer our own versions instead of mockito's dependency
|
// prefer our own versions instead of mockito's dependency
|
||||||
|
|
Loading…
Reference in New Issue