-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
build.gradle
140 lines (118 loc) · 4.6 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
plugins {
id "java-library"
id "maven-publish"
}
description = "gRPC: Servlet"
sourceSets {
// Testing threading is more of a brute-force test and is very slow. No need to run it as part
// of normal suite.
threadingTest {}
// Create a test sourceset for each classpath - could be simplified if we made new test directories
undertowTest {}
tomcatTest {}
// Only compile these tests if java 11+ is being used
if (JavaVersion.current().isJava11Compatible()) {
jettyTest {}
}
}
configurations {
itImplementation.extendsFrom(implementation)
undertowTestImplementation.extendsFrom(itImplementation)
tomcatTestImplementation.extendsFrom(itImplementation)
jettyTestImplementation.extendsFrom(itImplementation)
}
tasks.named("jar").configure {
manifest {
attributes('Automatic-Module-Name': 'io.grpc.servlet')
}
}
dependencies {
api project(':grpc-api')
compileOnly libraries.javax.servlet.api,
libraries.javax.annotation // java 9, 10 needs it
implementation project(':grpc-core'),
libraries.guava
testImplementation libraries.javax.servlet.api
threadingTestImplementation project(':grpc-servlet'),
libraries.truth,
libraries.javax.servlet.api,
libraries.lincheck
itImplementation project(':grpc-servlet'),
project(':grpc-netty'),
testFixtures(project(':grpc-core')),
libraries.junit
itImplementation(project(':grpc-interop-testing')) {
// Avoid grpc-netty-shaded dependency
exclude group: 'io.grpc', module: 'grpc-alts'
exclude group: 'io.grpc', module: 'grpc-xds'
}
undertowTestImplementation libraries.undertow.servlet22
tomcatTestImplementation libraries.tomcat.embed.core9
jettyTestImplementation libraries.jetty.servlet10,
libraries.jetty.http2.server10,
libraries.jetty.client,
project(':grpc-testing'),
libraries.truth,
libraries.protobuf.java
}
tasks.named("test").configure {
if (JavaVersion.current().isJava9Compatible()) {
jvmArgs += [
// required for Lincheck
'--add-opens=java.base/jdk.internal.misc=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.util=ALL-UNNAMED',
]
}
}
tasks.register('threadingTest', Test) {
classpath = sourceSets.threadingTest.runtimeClasspath
testClassesDirs = sourceSets.threadingTest.output.classesDirs
}
tasks.named("assemble").configure {
dependsOn tasks.named('compileThreadingTestJava')
}
// Set up individual classpaths for each test, to avoid any mismatch,
// and ensure they are only used when supported by the current jvm
def undertowTest = tasks.register('undertowTest', Test) {
classpath = sourceSets.undertowTest.runtimeClasspath
testClassesDirs = sourceSets.undertowTest.output.classesDirs
}
def tomcat9Test = tasks.register('tomcat9Test', Test) {
classpath = sourceSets.tomcatTest.runtimeClasspath
testClassesDirs = sourceSets.tomcatTest.output.classesDirs
// Provide a temporary directory for tomcat to be deleted after test finishes
def tomcatTempDir = "$buildDir/tomcat_catalina_base"
systemProperty 'catalina.base', tomcatTempDir
doLast {
file(tomcatTempDir).deleteDir()
}
// tomcat-embed-core 9 presently performs illegal reflective access on
// java.io.ObjectStreamClass$Caches.localDescs and sun.rmi.transport.Target.ccl,
// see https://lists.apache.org/thread/s0xr7tk2kfkkxfjps9n7dhh4cypfdhyy
if (JavaVersion.current().isJava9Compatible()) {
jvmArgs += ['--add-opens=java.base/java.io=ALL-UNNAMED', '--add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED']
}
}
tasks.named("check").configure {
dependsOn undertowTest, tomcat9Test
}
tasks.named("jacocoTestReport").configure {
// Must use executionData(Task...) override. The executionData(Object...) override doesn't find
// execution data correctly for tasks.
executionData undertowTest.get(), tomcat9Test.get()
}
// Only run these tests if java 11+ is being used
if (JavaVersion.current().isJava11Compatible()) {
def jettyTest = tasks.register('jettyTest', Test) {
classpath = sourceSets.jettyTest.runtimeClasspath
testClassesDirs = sourceSets.jettyTest.output.classesDirs
}
tasks.named("check").configure {
dependsOn jettyTest
}
tasks.named("jacocoTestReport").configure {
// Must use executionData(Task...) override. The executionData(Object...) override doesn't
// find execution data correctly for tasks.
executionData jettyTest.get()
}
}