forked from kinecosystem/kin-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
235 lines (204 loc) · 8.2 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
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:5.2.0'
}
}
apply plugin: 'java-library'
apply plugin: 'kotlin'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'maven-publish'
apply plugin: "signing"
enableJacoco(project, 'debug')
configurations {
shaded.extendsFrom(shadow)
}
// Our goal is to shade our 'hard to resolve conflicts' dependencies & transitive deps
// since downstream this can get really hard to manage if there are conflicts with these.
def groupsToShade = ['io.grpc',
'com.google.protobuf',
'com.google.guava',
'com.google.code.gson',
'com.google.code.findbugs',
'com.google.errorprone',
'com.google.re2j',
'com.google.j2objc',
'org.codehaus.mojo',
'org.checkerframework',
'commons-validator',
'io.opencensus',
'com.github.kinecosystem',
'org.kin.agora.gen',
groupId]
// Output to build/libs/base-shaded.jar
shadowJar {
dependsOn assemble
archiveClassifier.set ''
archiveBaseName.set 'base-shaded'
relocate 'io.grpc', 'org.kin.shaded.io.grpc'
relocate 'com.google', 'org.kin.shaded.com.google'
relocate 'javax.annotation', 'org.kin.shaded.javax.annotation'
relocate 'org.codehaus', 'org.kin.shaded.org.codehaus'
relocate 'org.checkerframework', 'org.kin.shaded.org.checkerframework'
relocate 'org.apache', 'org.kin.shaded.org.apache'
relocate 'io.opencensus', 'org.kin.shaded.io.opencensus'
relocate 'google.protobuf', 'org.kin.shaded.google.protobuf'
dependencies {
exclude(dependency {
it.moduleGroup == '.*'
})
include(dependency {
groupsToShade.contains(it.moduleGroup)
})
include(project(':base-storage'))
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation deps.kotlin_stdlib
implementation deps.gson
implementation deps.okhttp
implementation deps.i2p_crypto_eddsa
implementation deps.slf4j
implementation deps.grpc_stub
implementation deps.grpc_protobuf
implementation deps.grpc_okhttp
api deps.agora_api
api project(':base-storage')
implementation 'com.github.joshjdevl.libsodiumjni:libsodium-jni:2.0.1'
implementation 'org.json:json:20190722'
testImplementation deps.kotlin_stdlib
testImplementation deps.kotlin_junit
testImplementation deps.kotlinMockito
testImplementation deps.grpc_netty_shaded
// testImplementation deps.grpc_netty_tcnative_boringssl_static
testImplementation "org.conscrypt:conscrypt-openjdk-uber:2.2.1"
testImplementation deps.okhttp_mockwebserver
testImplementation deps.grpc_testing
}
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives sourcesJar
archives javadocJar
}
task testDebugUnitTest(type: Test)
task testReleaseUnitTest(type: Test)
version = libraryVersion
group = groupId
afterEvaluate {
publishing {
publications {
normal(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom {
name = 'base'
description = "Kin Android SDK Base"
url = 'https://github.com/kinecosystem/kin-android/tree/master/base'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/kinecosystem/kin-android/blob/master/LICENSE.md'
}
}
scm {
connection = 'scm:git:github.com/kinecosystem/kin-android.git'
developerConnection = 'scm:git:ssh://github.com/kinecosystem/kin-android.git'
url = 'https://github.com/kinecosystem/kin-android/tree/master/base'
}
developers {
developer {
id = 'kin-ci'
name = 'Kin CI'
email = '[email protected]'
}
}
}
}
shaded(MavenPublication) {
artifactId "base-shaded"
group groupId
version libraryVersion
artifact shadowJar
artifact sourcesJar
artifact javadocJar
pom {
packaging 'jar'
name = 'base-shaded'
description = "Kin Android SDK Base Shaded"
url = 'https://github.com/kinecosystem/kin-android/tree/master/base'
licenses {
license {
name = 'MIT License'
url = 'https://github.com/kinecosystem/kin-android/blob/master/LICENSE.md'
}
}
scm {
connection = 'scm:git:github.com/kinecosystem/kin-android.git'
developerConnection = 'scm:git:ssh://github.com/kinecosystem/kin-android.git'
url = 'https://github.com/kinecosystem/kin-android/tree/master/base'
}
developers {
developer {
id = 'kin-ci'
name = 'Kin CI'
email = '[email protected]'
}
}
withXml {
def root = asNode()
// root.appendNode("name", 'base-shaded')
// root.appendNode("url", siteUrl)
root.children().last() //+ pomConfig
def depsNode = root["dependencies"][0] ?: root.appendNode("dependencies")
def addDep = {
if (it.group == null) return // Avoid empty dependency nodes
def dependencyNode = depsNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
if (it.hasProperty('optional') && it.optional) {
dependencyNode.appendNode('optional', 'true')
}
dependencyNode.appendNode("scope", "runtime")
}
// Add deps that everyone has
configurations.implementation.dependencies.findAll {
if (!groupsToShade.contains(it.group)) {
it
}
}.each addDep
// Add api deps also
configurations.api.dependencies.findAll {
if (!groupsToShade.contains(it.group)) {
it
}
}.each addDep
// Add flavor specific deps
configurations["shaded"].allDependencies.each addDep
// NOTE: This library doesn't use builtTypes specific dependencies, so no need to add them.
}
}
}
}
}
}
ext["signing.keyId"] = rootProject.ext["signing.keyId"]
ext["signing.password"] = rootProject.ext["signing.password"]
ext["signing.secretKeyRingFile"] = rootProject.ext["signing.secretKeyRingFile"]
signing {
sign publishing.publications
}