/
build.gradle
281 lines (244 loc) · 10 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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
loadConfig('config.gradle')
// Publishing settings
project.group = config.publish.group
project.version = config.publish.versionName
project.ext.POM_ARTIFACT_ID = config.publish.artifactId
buildscript {
repositories {
mavenLocal()
google()
mavenCentral()
jcenter()
maven {
url 'https://jitpack.io'
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
//noinspection GradlePluginVersion
classpath "com.android.tools.build:gradle:_"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:_"
classpath "org.jetbrains.kotlin:kotlin-allopen:_"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:_"
classpath "com.google.protobuf:protobuf-gradle-plugin:_"
classpath 'com.github.str4d:rust-android-gradle:68b4ecc053'
classpath 'org.owasp:dependency-check-gradle:_'
classpath 'com.vanniktech:gradle-maven-publish-plugin:_'
}
}
apply from: 'custom-tasks.gradle'
apply from: "$rootDir/ktlint.gradle"
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlin-allopen'
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'com.google.protobuf'
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
apply plugin: 'org.owasp.dependencycheck'
apply plugin: 'com.vanniktech.maven.publish'
//apply from: 'ci.gradle'
repositories {
google()
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
}
android {
compileSdkVersion config.compileSdkVersion
useLibrary 'android.test.runner'
ndkVersion "21.1.6352462"
defaultConfig {
minSdkVersion config.minSdkVersion
targetSdkVersion config.targetSdkVersion
versionCode = config.publish.versionCode
versionName = config.publish.versionName
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
multiDexEnabled true
archivesBaseName = "zcash-android-sdk-${config.publish.name}"
javaCompileOptions {
annotationProcessorOptions {
arguments = ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
buildTypes {
debug {
// for test builds, which exceed the dex limit because they pull in things like mockito and grpc-testing
multiDexEnabled true
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
release {
multiDexEnabled false
minifyEnabled false
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
sourceSets {
main {
java {
srcDirs "build/generated/source/grpc"
}
proto {
srcDir 'src/main/proto'
}
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
// ExperimentalCoroutinesApi and FlowPreview help to clear the build warnings
kotlinOptions {
jvmTarget = "1.8"
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi"
freeCompilerArgs += "-Xopt-in=kotlinx.coroutines.FlowPreview"
// Tricky: fix: By default, the kotlin_module name will not include the version (in classes.jar/META-INF). Instead it has a colon, which breaks compilation on Windows. This is one way to set it explicitly to the proper value. See https://github.com/zcash/zcash-android-wallet-sdk/issues/222 for more info.
freeCompilerArgs += ["-module-name", "${config.publish.artifactId}-${config.publish.versionName}_${config.publish.target}"]
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/LICENSE.md'
exclude 'META-INF/LICENSE-notice.md'
}
}
mavenPublish {
androidVariantToPublish = config.publish.target
}
allOpen {
// marker for classes that we want to be able to extend in debug builds for testing purposes
annotation 'cash.z.ecc.android.sdk.annotation.OpenClass'
}
clean {
delete "$project.projectDir/src/generated/source/grpc"
}
dokkaHtml.configure {
dokkaSourceSets {
configureEach {
outputDirectory.set(file("build/docs/rtd"))
displayName.set("Zcash Android SDK")
includes.from("packages.md")
// samples.from("samples/basic.kt", "samples/advanced.kt")
}
}
}
protobuf {
generatedFilesBaseDir = "$projectDir/src/generated/source/grpc"
protoc { artifact = 'com.google.protobuf:protoc:3.14.0' }
plugins {
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.37.0" }
}
generateProtoTasks {
all().each { task ->
task.builtins {
java {
option "lite"
}
}
task.plugins {
grpc {
option 'lite'
}
}
}
}
}
cargo {
module = "."
libname = "zcashwalletsdk"
targets = [
"arm",
"arm64",
"x86",
"x86_64"
]
profile = "release"
forceTargets = true
prebuiltToolchains = true
}
dependencies {
implementation AndroidX.appCompat
// Architecture Components: Lifecycle
implementation AndroidX.lifecycle.runtimeKtx
implementation AndroidX.lifecycle.commonJava8
// Architecture Components: Room
implementation AndroidX.room.ktx
implementation AndroidX.paging.runtimeKtx
kapt AndroidX.room.compiler
// Kotlin
implementation Kotlin.stdlib.jdk8
implementation KotlinX.coroutines.core
implementation KotlinX.coroutines.android
// grpc-java
implementation "io.grpc:grpc-okhttp:_"
implementation "io.grpc:grpc-android:_"
implementation "io.grpc:grpc-protobuf-lite:_"
implementation "io.grpc:grpc-stub:_"
compileOnly 'javax.annotation:javax.annotation-api:_'
//
// Locked Versions
// these should be checked regularly and removed when possible
// solves error: Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules jetified-guava-26.0-android.jar (com.google.guava:guava:26.0-android) and listenablefuture-1.0.jar (com.google.guava:listenablefuture:1.0)
// per this recommendation from Chris Povirk, given guava's decision to split ListenableFuture away from Guava: https://groups.google.com/d/msg/guava-discuss/GghaKwusjcY/bCIAKfzOEwAJ
implementation 'com.google.guava:guava:30.0-android'
// Transitive dependencies used because they're already necessary for other libraries
// GSON is available as a transitive dependency from several places so we use it for processing
// checkpoints but also document that by explicitly including here. If dependencies like Room
// or grpc-okhttp stop including GSON, then we should switch to something else for parsing JSON.
implementation 'com.google.code.gson:gson:2.8.6'
// OKIO is a transitive dependency used when writing param files to disk. Like GSON, this can be
// replaced if needed. For compatibility, we match the library version used in grpc-okhttp:
// https://github.com/grpc/grpc-java/blob/v1.37.x/build.gradle#L159
implementation 'com.squareup.okio:okio:1.17.5'
// Tests
testImplementation 'androidx.multidex:multidex:_'
testImplementation "org.jetbrains.kotlin:kotlin-reflect:_"
testImplementation 'org.mockito:mockito-junit-jupiter:_'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:_'
testImplementation "org.junit.jupiter:junit-jupiter-api:_"
testImplementation "org.junit.jupiter:junit-jupiter-engine:_"
testImplementation "org.junit.jupiter:junit-jupiter-migrationsupport:_"
testImplementation "io.grpc:grpc-testing:_"
// NOTE: androidTests will use JUnit4, while src/test/java tests will leverage Junit5
// Attempting to use JUnit5 via https://github.com/mannodermaus/android-junit5 was painful. The plugin configuration
// was buggy, crashing in several places. It also would require a separate test flavor because it's minimum API 26
// because "JUnit 5 uses Java 8-specific APIs that didn't exist on Android before the Oreo release."
androidTestImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:_'
androidTestImplementation 'org.mockito:mockito-android:_'
androidTestImplementation "androidx.test:runner:_"
androidTestImplementation 'com.android.support:support-annotations:_'
androidTestImplementation "androidx.test:core:_"
androidTestImplementation "androidx.arch.core:core-testing:_"
androidTestImplementation 'androidx.test.ext:junit:_'
androidTestImplementation 'ru.gildor.coroutines:kotlin-coroutines-okhttp:_'
// used by 'ru.gildor.coroutines.okhttp.await' (to make simple suspended requests) and breaks on versions higher than 3.8.0
androidTestImplementation "com.squareup.okhttp3:okhttp:3.8.0"
// sample mnemonic plugin
androidTestImplementation 'com.github.zcash:zcash-android-wallet-plugins:_'
androidTestImplementation 'cash.z.ecc.android:kotlin-bip39:_'
}
//taskTree{
// noRepeat = true //do not print a sub-tree in the task-tree more than once
// impliesSubProjects = true //do not print task-tree for child projects in a multi-project
// taskDepth = 2 // limit tree depth to 3. Equivalent to running with the --task-depth option.
//}
defaultTasks 'ciBuild'
preBuild.dependsOn('ktlintFormat')
preBuild.dependsOn('ktlint')
preBuild.dependsOn includeDirBugFix
//check.dependsOn dependencyCheckAggregate
def loadConfig(fileName) {
def config = new ConfigSlurper().parse(file(fileName).toURL())
project.ext.config = config
}