forked from grpc/grpc-java
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle
75 lines (65 loc) · 2.57 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
plugins {
id "java"
id "maven-publish"
id "com.github.johnrengelman.shadow"
}
description = "gRPC: Netty Shaded"
sourceSets { testShadow {} }
dependencies {
implementation project(':grpc-netty')
runtimeOnly libraries.netty_tcnative,
libraries.netty_epoll
testShadowImplementation files(shadowJar),
project(':grpc-testing-proto'),
project(':grpc-testing'),
libraries.truth
shadow project(':grpc-core')
}
jar {
// Must use a different classifier to avoid conflicting with shadowJar
classifier = 'original'
}
shadowJar {
classifier = null
dependencies {
include(project(':grpc-netty'))
include(dependency('io.netty:'))
}
relocate 'io.grpc.netty', 'io.grpc.netty.shaded.io.grpc.netty'
relocate 'io.netty', 'io.grpc.netty.shaded.io.netty'
// We have to be careful with these replacements as they must not match any
// string in NativeLibraryLoader, else they cause corruption. Note that
// this includes concatenation of string literals and constants.
relocate 'META-INF/native/libnetty', 'META-INF/native/libio_grpc_netty_shaded_netty'
relocate 'META-INF/native/netty', 'META-INF/native/io_grpc_netty_shaded_netty'
mergeServiceFiles()
}
publishing {
publications {
maven(MavenPublication) {
// Ideally swap to project.shadow.component(it) when it isn't broken for project deps
artifact shadowJar
// Empty jars are not published via withJavadocJar() and withSourcesJar()
artifact javadocJar
artifact sourcesJar
pom.withXml {
def dependencies = asNode().appendNode('dependencies')
project.configurations.shadow.allDependencies.each { dep ->
def dependencyNode = dependencies.appendNode('dependency')
dependencyNode.appendNode('groupId', dep.group)
dependencyNode.appendNode('artifactId', dep.name)
def version = (dep.name == 'grpc-core') ? '[' + dep.version + ']' : dep.version
dependencyNode.appendNode('version', version)
dependencyNode.appendNode('scope', 'compile')
}
}
}
}
}
task testShadow(type: Test) {
testClassesDirs = sourceSets.testShadow.output.classesDirs
classpath = sourceSets.testShadow.runtimeClasspath
}
compileTestShadowJava.options.compilerArgs = compileTestJava.options.compilerArgs
compileTestShadowJava.options.encoding = compileTestJava.options.encoding
test.dependsOn testShadow