-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
build.gradle
244 lines (220 loc) · 7.93 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
import io.grpc.gradle.CheckPackageLeakageTask;
plugins {
id "java"
id "maven-publish"
id "com.github.johnrengelman.shadow"
id "com.google.protobuf"
id "ru.vyarus.animalsniffer"
}
description = "gRPC: XDS plugin"
sourceSets {
thirdparty {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/main/java"
}
proto {
srcDir 'third_party/envoy/src/main/proto'
srcDir 'third_party/protoc-gen-validate/src/main/proto'
srcDir 'third_party/xds/src/main/proto'
srcDir 'third_party/googleapis/src/main/proto'
srcDir 'third_party/istio/src/main/proto'
}
}
main {
output.classesDirs.from(sourceSets.thirdparty.output.classesDirs)
}
test {
java {
srcDir "${projectDir}/third_party/zero-allocation-hashing/test/java"
}
}
}
configurations {
pomDeps {
extendsFrom configurations.thirdpartyRuntimeClasspath, configurations.shadow
}
}
dependencies {
thirdpartyCompileOnly libraries.javax.annotation
thirdpartyImplementation project(':grpc-protobuf'),
project(':grpc-stub'),
libraries.opencensus.proto
compileOnly sourceSets.thirdparty.output
implementation project(':grpc-stub'),
project(':grpc-core'),
project(':grpc-util'),
project(':grpc-services'),
project(':grpc-auth'),
project(path: ':grpc-alts', configuration: 'shadow'),
libraries.gson,
libraries.re2j,
libraries.auto.value.annotations,
libraries.protobuf.java.util
def nettyDependency = implementation project(':grpc-netty')
testImplementation project(':grpc-rls')
testImplementation project(':grpc-inprocess')
testImplementation testFixtures(project(':grpc-core')),
testFixtures(project(':grpc-api')),
testFixtures(project(':grpc-util'))
annotationProcessor libraries.auto.value
// At runtime use the epoll included in grpc-netty-shaded
compileOnly libraries.netty.transport.epoll
testImplementation project(':grpc-testing'),
project(':grpc-testing-proto')
testImplementation (libraries.netty.transport.epoll) {
artifact {
classifier = "linux-x86_64"
}
}
testImplementation libraries.guava.testlib
shadow configurations.implementation.getDependencies().minus([nettyDependency])
shadow project(path: ':grpc-netty-shaded', configuration: 'shadow')
signature libraries.signature.java
testRuntimeOnly libraries.netty.tcnative,
libraries.netty.tcnative.classes
testRuntimeOnly (libraries.netty.tcnative) {
artifact {
classifier = "linux-x86_64"
}
}
testRuntimeOnly (libraries.netty.tcnative) {
artifact {
classifier = "linux-aarch_64"
}
}
testRuntimeOnly (libraries.netty.tcnative) {
artifact {
classifier = "osx-x86_64"
}
}
testRuntimeOnly (libraries.netty.tcnative) {
artifact {
classifier = "osx-aarch_64"
}
}
testRuntimeOnly (libraries.netty.tcnative) {
artifact {
classifier = "windows-x86_64"
}
}
}
configureProtoCompilation()
tasks.named("compileThirdpartyJava").configure {
options.errorprone.enabled = false
options.compilerArgs += [
// valueOf(int) in RoutingPriority has been deprecated
"-Xlint:-deprecation",
]
}
tasks.named("checkstyleThirdparty").configure {
enabled = false
}
tasks.named("compileJava").configure {
it.options.compilerArgs += [
// TODO: remove
"-Xlint:-deprecation",
// only has AutoValue annotation processor
"-Xlint:-processing",
]
appendToProperty(
it.options.errorprone.excludedPaths,
".*/build/generated/sources/annotationProcessor/java/.*",
"|")
// remove after upgrade error-prone
appendToProperty(
it.options.errorprone.excludedPaths,
".*/build/tmp/compileJava/compileTransaction/annotation-output/io/grpc/xds/.*",
"|")
}
tasks.named("jar").configure {
archiveClassifier = 'original'
manifest {
attributes('Automatic-Module-Name': 'io.grpc.xds')
}
}
tasks.named("sourcesJar").configure {
from sourceSets.thirdparty.allSource
}
tasks.named("javadoc").configure {
// Exclusions here should generally also be relocated
exclude 'com/github/udpa/**'
exclude 'com/github/xds/**'
exclude 'com/google/security/**'
exclude 'io/envoyproxy/**'
// Need to clean up the class structure to reduce how much is exposed
exclude 'io/grpc/xds/client/**'
exclude 'io/grpc/xds/*LoadBalancer*'
exclude 'io/grpc/xds/Bootstrapper.java'
exclude 'io/grpc/xds/Envoy*'
exclude 'io/grpc/xds/FilterChainMatchingProtocolNegotiators.java'
exclude 'io/grpc/xds/TlsContextManager.java'
exclude 'io/grpc/xds/XdsAttributes.java'
exclude 'io/grpc/xds/XdsCredentialsProvider.java'
exclude 'io/grpc/xds/XdsInitializationException.java'
exclude 'io/grpc/xds/XdsNameResolverProvider.java'
exclude 'io/grpc/xds/internal/**'
exclude 'io/grpc/xds/Internal*'
}
def prefixName = 'io.grpc.xds'
tasks.named("shadowJar").configure {
archiveClassifier = null
dependencies {
include(project(':grpc-xds'))
}
// Relocated packages commonly need exclusions in jacocoTestReport and javadoc
relocate 'com.github.udpa', "${prefixName}.shaded.com.github.udpa"
relocate 'com.github.xds', "${prefixName}.shaded.com.github.xds"
relocate 'com.google.api.expr', "${prefixName}.shaded.com.google.api.expr"
relocate 'com.google.security', "${prefixName}.shaded.com.google.security"
// TODO: missing java_package option in .proto
relocate 'envoy.annotations', "${prefixName}.shaded.envoy.annotations"
relocate 'io.envoyproxy', "${prefixName}.shaded.io.envoyproxy"
relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty'
relocate 'io.netty', 'io.grpc.netty.shaded.io.netty'
// TODO: missing java_package option in .proto
relocate 'udpa.annotations', "${prefixName}.shaded.udpa.annotations"
relocate 'xds.annotations', "${prefixName}.shaded.xds.annotations"
exclude "**/*.proto"
}
def checkPackageLeakage = tasks.register("checkPackageLeakage", CheckPackageLeakageTask) {
files.from tasks.named('shadowJar')
prefix = prefixName
}
tasks.named("test").configure {
dependsOn checkPackageLeakage
}
tasks.named("jacocoTestReport").configure {
classDirectories.from = sourceSets.main.output.collect {
fileTree(dir: it,
exclude: [ // Exclusions here should generally also be relocated
'**/com/github/udpa/**',
'**/com/github/xds/**',
'**/com/google/api/expr/**',
'**/com/google/security/**',
'**/envoy/annotations/**',
'**/io/envoyproxy/**',
'**/udpa/annotations/**',
'**/xds/annotations/**',
])
}
}
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.pomDeps.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)
}
}
}
}