mirror of https://github.com/grpc/grpc-java.git
Use test fixtures instead of sourceSets.test.output
This avoids the (often missing) evaluationDependsOn and fixes using results from other projects without propagating those through Configuration. It also reduces the number of useless classes pulled in by down-stream tests, reducing the probability of rebuilds. The expectation of fixtures is they help testing down-stream code that use the classes in main. That applies to all the classes here except for FakeClock and StaticTestingClassLoader. It would also apply to many internal classes in grpc-testing, but let's consider cleaning that up future work.
This commit is contained in:
parent
cd7b81c6d2
commit
29b8483fd6
|
@ -9,8 +9,6 @@ plugins {
|
|||
|
||||
description = "gRPC: ALTS"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-core')
|
||||
implementation project(':grpc-auth'),
|
||||
|
@ -28,7 +26,7 @@ dependencies {
|
|||
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')
|
||||
|
||||
testImplementation project(':grpc-testing'),
|
||||
project(':grpc-core').sourceSets.test.output,
|
||||
testFixtures(project(':grpc-core')),
|
||||
project(':grpc-testing-proto'),
|
||||
libraries.guava,
|
||||
libraries.junit,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
id "java-library"
|
||||
id "java-test-fixtures"
|
||||
id "maven-publish"
|
||||
|
||||
id "me.champeau.jmh"
|
||||
|
@ -8,15 +9,16 @@ plugins {
|
|||
|
||||
description = 'gRPC: API'
|
||||
|
||||
evaluationDependsOn(project(':grpc-context').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-context'),
|
||||
libraries.jsr305,
|
||||
libraries.errorprone.annotations
|
||||
implementation libraries.guava
|
||||
|
||||
testImplementation project(':grpc-context').sourceSets.test.output,
|
||||
testFixturesImplementation libraries.guava,
|
||||
libraries.junit,
|
||||
libraries.mockito.core
|
||||
testImplementation testFixtures(project(':grpc-context')),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-grpclb')
|
||||
testImplementation (libraries.guava.testlib) {
|
||||
|
@ -32,3 +34,6 @@ tasks.named("javadoc").configure {
|
|||
// We want io.grpc.Internal, but not io.grpc.Internal*
|
||||
exclude 'io/grpc/Internal?*.java'
|
||||
}
|
||||
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
|
||||
|
|
|
@ -19,7 +19,7 @@ dependencies {
|
|||
|
||||
testImplementation project(':grpc-testing'),
|
||||
project(':grpc-testing-proto'),
|
||||
project(':grpc-core').sourceSets.test.output // for FakeClock
|
||||
testFixtures(project(':grpc-core'))
|
||||
testImplementation (libraries.guava.testlib) {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
|
|
|
@ -7,22 +7,6 @@ description = 'gRPC BinderChannel'
|
|||
|
||||
android {
|
||||
namespace 'io.grpc.binder'
|
||||
sourceSets {
|
||||
test {
|
||||
java {
|
||||
srcDirs += "${projectDir}/../core/src/test/java/"
|
||||
setIncludes(["io/grpc/internal/FakeClock.java",
|
||||
"io/grpc/binder/**"])
|
||||
}
|
||||
}
|
||||
androidTest {
|
||||
java {
|
||||
srcDirs += "${projectDir}/../core/src/test/java/"
|
||||
setIncludes(["io/grpc/internal/AbstractTransportTest.java",
|
||||
"io/grpc/binder/**"])
|
||||
}
|
||||
}
|
||||
}
|
||||
compileSdkVersion 31
|
||||
compileOptions {
|
||||
sourceCompatibility 1.8
|
||||
|
@ -72,6 +56,7 @@ dependencies {
|
|||
}
|
||||
testImplementation libraries.truth
|
||||
testImplementation project(':grpc-testing')
|
||||
testImplementation testFixtures(project(':grpc-core'))
|
||||
|
||||
androidTestAnnotationProcessor libraries.auto.value
|
||||
androidTestImplementation project(':grpc-testing')
|
||||
|
@ -88,6 +73,7 @@ dependencies {
|
|||
androidTestImplementation (libraries.guava.testlib) {
|
||||
exclude group: 'junit', module: 'junit'
|
||||
}
|
||||
androidTestImplementation testFixtures(project(':grpc-core'))
|
||||
}
|
||||
|
||||
import net.ltgt.gradle.errorprone.CheckSeverity
|
||||
|
|
|
@ -7,17 +7,15 @@ plugins {
|
|||
|
||||
description = 'gRPC: Census'
|
||||
|
||||
evaluationDependsOn(project(':grpc-api').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-api')
|
||||
implementation libraries.guava,
|
||||
libraries.opencensus.api,
|
||||
libraries.opencensus.contrib.grpc.metrics
|
||||
|
||||
testImplementation project(':grpc-api').sourceSets.test.output,
|
||||
project(':grpc-context').sourceSets.test.output,
|
||||
project(':grpc-core').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-api')),
|
||||
testFixtures(project(':grpc-context')),
|
||||
testFixtures(project(':grpc-core')),
|
||||
project(':grpc-testing'),
|
||||
libraries.opencensus.impl
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
plugins {
|
||||
id "java"
|
||||
id "java-test-fixtures"
|
||||
id "maven-publish"
|
||||
|
||||
id "me.champeau.gradle.japicmp"
|
||||
|
@ -13,6 +14,10 @@ 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
|
||||
|
@ -23,3 +28,6 @@ dependencies {
|
|||
signature "org.codehaus.mojo.signature:java17:1.0@signature"
|
||||
signature "net.sf.androidscents.signature:android-api-level-14:4.0_r4@signature"
|
||||
}
|
||||
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
|
||||
|
|
|
@ -6,6 +6,7 @@ buildscript {
|
|||
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "java-test-fixtures"
|
||||
id "maven-publish"
|
||||
|
||||
id "me.champeau.gradle.japicmp"
|
||||
|
@ -19,9 +20,6 @@ import com.google.common.primitives.Bytes;
|
|||
|
||||
description = 'gRPC: Core'
|
||||
|
||||
evaluationDependsOn(project(':grpc-context').path)
|
||||
evaluationDependsOn(project(':grpc-api').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-api')
|
||||
implementation libraries.gson,
|
||||
|
@ -30,8 +28,13 @@ dependencies {
|
|||
libraries.errorprone.annotations,
|
||||
libraries.guava,
|
||||
libraries.perfmark.api
|
||||
testImplementation project(':grpc-context').sourceSets.test.output,
|
||||
project(':grpc-api').sourceSets.test.output,
|
||||
testFixturesApi libraries.junit
|
||||
testFixturesImplementation libraries.guava,
|
||||
libraries.mockito.core,
|
||||
libraries.truth,
|
||||
project(':grpc-testing')
|
||||
testImplementation testFixtures(project(':grpc-context')),
|
||||
testFixtures(project(':grpc-api')),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-grpclb')
|
||||
testImplementation (libraries.guava.testlib) {
|
||||
|
@ -61,6 +64,9 @@ animalsniffer {
|
|||
]
|
||||
}
|
||||
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesApiElements) { skip() }
|
||||
components.java.withVariantsFromConfiguration(configurations.testFixturesRuntimeElements) { skip() }
|
||||
|
||||
import net.ltgt.gradle.errorprone.CheckSeverity
|
||||
|
||||
def replaceBytes(byte[] haystack, byte[] needle, byte[] replacement) {
|
||||
|
|
|
@ -62,7 +62,7 @@ dependencies {
|
|||
('io.opencensus:opencensus-api:0.31.1'),
|
||||
('com.google.guava:guava:31.1-jre')
|
||||
|
||||
testImplementation project(':grpc-context').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-context')),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-testing-proto')
|
||||
testImplementation (libraries.guava.testlib) {
|
||||
|
|
|
@ -13,7 +13,7 @@ dependencies {
|
|||
project(':grpc-core'),
|
||||
project(path: ':grpc-xds', configuration: 'shadow'),
|
||||
libraries.guava.jre // JRE required by transitive protobuf-java-util
|
||||
testImplementation project(':grpc-core').sourceSets.test.output
|
||||
testImplementation testFixtures(project(':grpc-core'))
|
||||
|
||||
signature libraries.signature.java
|
||||
}
|
||||
|
|
|
@ -9,8 +9,6 @@ plugins {
|
|||
|
||||
description = "gRPC: GRPCLB LoadBalancer plugin"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
implementation project(':grpc-core'),
|
||||
project(':grpc-protobuf'),
|
||||
|
@ -21,7 +19,7 @@ dependencies {
|
|||
runtimeOnly libraries.errorprone.annotations
|
||||
compileOnly libraries.javax.annotation
|
||||
testImplementation libraries.truth,
|
||||
project(':grpc-core').sourceSets.test.output
|
||||
testFixtures(project(':grpc-core'))
|
||||
|
||||
signature libraries.signature.java
|
||||
}
|
||||
|
|
|
@ -13,10 +13,6 @@ configurations {
|
|||
alpnagent
|
||||
}
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
evaluationDependsOn(project(':grpc-context').path)
|
||||
evaluationDependsOn(project(':grpc-api').path)
|
||||
|
||||
dependencies {
|
||||
implementation project(path: ':grpc-alts', configuration: 'shadow'),
|
||||
project(':grpc-auth'),
|
||||
|
@ -49,9 +45,9 @@ dependencies {
|
|||
libraries.netty.tcnative.classes,
|
||||
project(':grpc-grpclb'),
|
||||
project(':grpc-rls')
|
||||
testImplementation project(':grpc-context').sourceSets.test.output,
|
||||
project(':grpc-api').sourceSets.test.output,
|
||||
project(':grpc-core').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-context')),
|
||||
testFixtures(project(':grpc-api')),
|
||||
testFixtures(project(':grpc-core')),
|
||||
libraries.mockito.core,
|
||||
libraries.okhttp
|
||||
alpnagent libraries.jetty.alpn.agent
|
||||
|
|
|
@ -13,8 +13,6 @@ configurations {
|
|||
alpnagent
|
||||
}
|
||||
|
||||
evaluationDependsOn(project(':grpc-context').path)
|
||||
|
||||
dependencies {
|
||||
implementation project(':grpc-core'),
|
||||
project(':grpc-netty'),
|
||||
|
@ -28,9 +26,9 @@ dependencies {
|
|||
|
||||
runtimeOnly libraries.netty.tcnative,
|
||||
libraries.netty.tcnative.classes
|
||||
testImplementation project(':grpc-context').sourceSets.test.output,
|
||||
project(':grpc-api').sourceSets.test.output,
|
||||
project(':grpc-core').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-context')),
|
||||
testFixtures(project(':grpc-api')),
|
||||
testFixtures(project(':grpc-core')),
|
||||
libraries.mockito.core,
|
||||
libraries.junit,
|
||||
libraries.truth
|
||||
|
|
|
@ -13,8 +13,6 @@ configurations {
|
|||
alpnagent
|
||||
}
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-core'),
|
||||
libraries.netty.codec.http2
|
||||
|
@ -25,8 +23,8 @@ dependencies {
|
|||
libraries.netty.unix.common
|
||||
|
||||
// Tests depend on base class defined by core module.
|
||||
testImplementation project(':grpc-core').sourceSets.test.output,
|
||||
project(':grpc-api').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-core')),
|
||||
testFixtures(project(':grpc-api')),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-testing-proto'),
|
||||
libraries.conscrypt,
|
||||
|
|
|
@ -8,8 +8,6 @@ plugins {
|
|||
|
||||
description = "gRPC: OkHttp"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-core')
|
||||
implementation libraries.okio,
|
||||
|
@ -18,8 +16,8 @@ dependencies {
|
|||
// Make okhttp dependencies compile only
|
||||
compileOnly libraries.okhttp
|
||||
// Tests depend on base class defined by core module.
|
||||
testImplementation project(':grpc-core').sourceSets.test.output,
|
||||
project(':grpc-api').sourceSets.test.output,
|
||||
testImplementation testFixtures(project(':grpc-core')),
|
||||
testFixtures(project(':grpc-api')),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-testing-proto'),
|
||||
libraries.netty.codec.http2,
|
||||
|
|
|
@ -8,8 +8,6 @@ plugins {
|
|||
|
||||
description = "gRPC: RouteLookupService Loadbalancing plugin"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
implementation project(':grpc-core'),
|
||||
project(':grpc-protobuf'),
|
||||
|
@ -22,7 +20,7 @@ dependencies {
|
|||
project(':grpc-grpclb'),
|
||||
project(':grpc-testing'),
|
||||
project(':grpc-testing-proto'),
|
||||
project(':grpc-core').sourceSets.test.output // for FakeClock
|
||||
testFixtures(project(':grpc-core'))
|
||||
signature libraries.signature.java
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,6 @@ tasks.named("compileJava").configure {
|
|||
]
|
||||
}
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-protobuf'),
|
||||
project(':grpc-stub'),
|
||||
|
@ -30,7 +28,7 @@ dependencies {
|
|||
compileOnly libraries.javax.annotation
|
||||
testImplementation project(':grpc-testing'),
|
||||
libraries.netty.transport.epoll, // for DomainSocketAddress
|
||||
project(':grpc-core').sourceSets.test.output // for FakeClock
|
||||
testFixtures(project(':grpc-core'))
|
||||
testCompileOnly libraries.javax.annotation
|
||||
signature libraries.signature.java
|
||||
}
|
||||
|
|
|
@ -8,8 +8,6 @@ plugins {
|
|||
|
||||
description = "gRPC: Testing"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
dependencies {
|
||||
api project(':grpc-core'),
|
||||
project(':grpc-stub'),
|
||||
|
@ -24,7 +22,7 @@ dependencies {
|
|||
}
|
||||
|
||||
testImplementation project(':grpc-testing-proto'),
|
||||
project(':grpc-core').sourceSets.test.output
|
||||
testFixtures(project(':grpc-core'))
|
||||
|
||||
signature libraries.signature.java
|
||||
signature libraries.signature.android
|
||||
|
|
|
@ -11,8 +11,6 @@ plugins {
|
|||
|
||||
description = "gRPC: XDS plugin"
|
||||
|
||||
evaluationDependsOn(project(':grpc-core').path)
|
||||
|
||||
sourceSets {
|
||||
thirdparty {
|
||||
java {
|
||||
|
@ -57,7 +55,7 @@ dependencies {
|
|||
def nettyDependency = implementation project(':grpc-netty')
|
||||
|
||||
testImplementation project(':grpc-rls')
|
||||
testImplementation project(':grpc-core').sourceSets.test.output
|
||||
testImplementation testFixtures(project(':grpc-core'))
|
||||
|
||||
annotationProcessor libraries.auto.value
|
||||
// At runtime use the epoll included in grpc-netty-shaded
|
||||
|
|
Loading…
Reference in New Issue