2021-04-09 18:41:55 -07:00
loadConfig ( 'config.gradle' )
// Publishing settings
project . group = config . publish . group
project . version = config . publish . versionName
project . ext . POM_ARTIFACT_ID = config . publish . artifactId
2020-06-10 00:08:19 -07:00
2018-11-20 23:01:45 -08:00
buildscript {
repositories {
2021-04-09 18:41:55 -07:00
mavenLocal ( )
2018-11-20 23:01:45 -08:00
google ( )
2021-04-09 18:41:55 -07:00
mavenCentral ( )
2018-11-20 23:01:45 -08:00
jcenter ( )
2019-04-18 15:56:52 -07:00
maven {
url 'https://jitpack.io'
}
2020-06-09 18:56:49 -07:00
maven {
url "https://plugins.gradle.org/m2/"
}
2018-11-20 23:01:45 -08:00
}
dependencies {
2021-04-23 12:00:45 -07:00
//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:_"
2019-07-26 13:55:50 -07:00
classpath 'com.github.str4d:rust-android-gradle:68b4ecc053'
2021-04-23 12:00:45 -07:00
classpath 'org.owasp:dependency-check-gradle:_'
classpath 'com.vanniktech:gradle-maven-publish-plugin:_'
2018-11-20 23:01:45 -08:00
}
}
2018-11-20 23:04:53 -08:00
apply from: 'custom-tasks.gradle'
2021-03-10 10:10:03 -08:00
apply from: "$rootDir/ktlint.gradle"
2018-11-20 23:04:53 -08:00
apply plugin: 'com.android.library'
2019-03-28 23:31:25 -07:00
apply plugin: 'kotlin-android'
2018-11-27 22:43:36 -08:00
apply plugin: 'kotlin-kapt'
2019-01-23 02:45:26 -08:00
apply plugin: 'kotlin-allopen'
2019-03-28 23:31:25 -07:00
apply plugin: 'org.jetbrains.dokka'
2019-01-02 21:31:12 -08:00
apply plugin: 'com.google.protobuf'
2019-04-18 15:56:52 -07:00
apply plugin: 'org.mozilla.rust-android-gradle.rust-android'
2019-06-17 02:01:29 -07:00
apply plugin: 'org.owasp.dependencycheck'
2021-04-09 16:50:59 -07:00
apply plugin: 'com.vanniktech.maven.publish'
//apply from: 'ci.gradle'
2018-11-21 01:48:26 -08:00
2018-11-20 23:04:53 -08:00
2018-11-20 23:01:45 -08:00
repositories {
google ( )
2021-04-29 12:57:13 -07:00
mavenCentral ( )
2018-11-20 23:04:53 -08:00
jcenter ( )
2020-02-11 17:31:56 -08:00
maven { url 'https://jitpack.io' }
2018-11-20 09:59:08 -08:00
}
android {
2021-04-09 18:41:55 -07:00
compileSdkVersion config . compileSdkVersion
2019-03-28 23:03:11 -07:00
useLibrary 'android.test.runner'
2018-11-20 09:59:08 -08:00
2020-06-09 18:56:49 -07:00
ndkVersion "21.1.6352462"
2018-11-20 09:59:08 -08:00
defaultConfig {
2021-04-09 18:41:55 -07:00
minSdkVersion config . minSdkVersion
targetSdkVersion config . targetSdkVersion
versionCode = config . publish . versionCode
versionName = config . publish . versionName
2018-11-27 21:49:03 -08:00
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2019-03-28 23:03:11 -07:00
testInstrumentationRunnerArguments clearPackageData: 'true'
multiDexEnabled true
2021-04-09 18:41:55 -07:00
archivesBaseName = "zcash-android-sdk-${config.publish.name}"
2020-02-21 15:16:25 -08:00
javaCompileOptions {
annotationProcessorOptions {
arguments = [ "room.schemaLocation" : "$projectDir/schemas" . toString ( ) ]
}
}
2018-11-20 09:59:08 -08:00
}
buildTypes {
2019-03-28 23:03:11 -07:00
debug {
// for test builds, which exceed the dex limit because they pull in things like mockito and grpc-testing
multiDexEnabled true
2019-06-14 16:04:18 -07:00
minifyEnabled false
2019-03-28 23:03:11 -07:00
proguardFiles getDefaultProguardFile ( "proguard-android-optimize.txt" ) , "proguard-rules.pro"
}
2018-11-20 23:04:53 -08:00
release {
2019-03-28 23:03:11 -07:00
multiDexEnabled false
2019-06-14 16:04:18 -07:00
minifyEnabled false
2018-11-20 23:04:53 -08:00
proguardFiles getDefaultProguardFile ( "proguard-android-optimize.txt" ) , "proguard-rules.pro"
}
}
2019-03-28 23:03:11 -07:00
2018-11-20 23:04:53 -08:00
sourceSets {
main {
java {
2019-01-02 21:31:12 -08:00
srcDirs "build/generated/source/grpc"
}
proto {
srcDir 'src/main/proto'
2018-11-20 23:04:53 -08:00
}
2018-11-20 09:59:08 -08:00
}
}
2019-02-19 10:09:01 -08:00
compileOptions {
2019-02-24 11:17:29 -08:00
sourceCompatibility JavaVersion . VERSION_1_8
targetCompatibility JavaVersion . VERSION_1_8
2019-02-19 10:09:01 -08:00
}
2020-12-04 06:28:55 -08:00
// 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"
2021-04-29 00:35:55 -07:00
// 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.
2021-04-26 14:36:15 -07:00
freeCompilerArgs + = [ "-module-name" , "${config.publish.artifactId}-${config.publish.versionName}_${config.publish.target}" ]
2020-12-04 06:28:55 -08:00
}
2019-01-13 07:37:23 -08:00
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'
}
2018-11-20 09:59:08 -08:00
}
2021-04-09 18:41:55 -07:00
mavenPublish {
androidVariantToPublish = config . publish . target
}
2018-11-20 09:59:08 -08:00
2019-01-23 02:45:26 -08:00
allOpen {
// marker for classes that we want to be able to extend in debug builds for testing purposes
2020-06-10 00:08:19 -07:00
annotation 'cash.z.ecc.android.sdk.annotation.OpenClass'
2019-01-23 02:45:26 -08:00
}
2019-01-02 21:31:12 -08:00
clean {
delete "$project.projectDir/src/generated/source/grpc"
}
2021-04-09 18:41:55 -07:00
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")
}
}
2019-03-28 23:31:25 -07:00
}
2021-04-09 18:41:55 -07:00
2019-01-02 21:31:12 -08:00
protobuf {
generatedFilesBaseDir = "$projectDir/src/generated/source/grpc"
2021-01-05 11:42:23 -08:00
protoc { artifact = 'com.google.protobuf:protoc:3.14.0' }
2019-01-02 21:31:12 -08:00
plugins {
2021-04-22 15:53:36 -07:00
grpc { artifact = "io.grpc:protoc-gen-grpc-java:1.37.0" }
2019-01-02 21:31:12 -08:00
}
generateProtoTasks {
all ( ) . each { task - >
2021-01-05 11:42:23 -08:00
task . builtins {
java {
option "lite"
}
}
2019-01-02 21:31:12 -08:00
task . plugins {
2021-01-05 11:42:23 -08:00
grpc {
2019-03-28 23:03:11 -07:00
option 'lite'
}
2019-01-02 21:31:12 -08:00
}
}
}
}
2019-04-18 15:56:52 -07:00
cargo {
module = "."
libname = "zcashwalletsdk"
targets = [
"arm" ,
"arm64" ,
"x86" ,
2020-06-11 11:00:06 -07:00
"x86_64"
2019-04-18 15:56:52 -07:00
]
profile = "release"
forceTargets = true
2019-11-26 12:46:31 -08:00
prebuiltToolchains = true
2019-04-18 15:56:52 -07:00
}
2018-11-20 09:59:08 -08:00
dependencies {
2019-07-12 01:47:17 -07:00
2021-04-22 15:53:36 -07:00
implementation AndroidX . appCompat
2018-11-20 23:04:53 -08:00
2019-03-12 10:05:38 -07:00
// Architecture Components: Lifecycle
2021-04-22 15:53:36 -07:00
implementation AndroidX . lifecycle . runtimeKtx
implementation AndroidX . lifecycle . commonJava8
2019-03-12 10:05:38 -07:00
// Architecture Components: Room
2021-04-22 15:53:36 -07:00
implementation AndroidX . room . ktx
implementation AndroidX . paging . runtimeKtx
kapt AndroidX . room . compiler
2018-11-27 22:43:36 -08:00
2019-03-12 10:05:38 -07:00
// Kotlin
2021-04-22 15:53:36 -07:00
implementation Kotlin . stdlib . jdk8
implementation KotlinX . coroutines . core
implementation KotlinX . coroutines . android
2019-01-02 21:31:12 -08:00
// grpc-java
2021-04-22 15:53:36 -07:00
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
2019-03-28 23:03:11 -07:00
// 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
2021-03-10 10:10:03 -08:00
implementation 'com.google.guava:guava:30.0-android'
2021-01-05 11:42:23 -08:00
// 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:
2021-04-09 19:05:33 -07:00
// https://github.com/grpc/grpc-java/blob/v1.37.x/build.gradle#L159
implementation 'com.squareup.okio:okio:1.17.5'
2021-01-05 11:42:23 -08:00
2018-11-28 15:15:36 -08:00
// Tests
2021-04-23 13:06:53 -07:00
testImplementation 'androidx.multidex:multidex:_'
2021-04-22 15:53:36 -07:00
testImplementation "org.jetbrains.kotlin:kotlin-reflect:_"
2021-04-23 13:06:53 -07:00
testImplementation 'org.mockito:mockito-junit-jupiter:_'
testImplementation 'com.nhaarman.mockitokotlin2:mockito-kotlin:_'
2021-04-22 15:53:36 -07:00
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:_"
2019-02-14 13:43:06 -08:00
2019-02-24 11:17:29 -08:00
// 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."
2021-04-23 13:06:53 -07:00
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:_'
2021-04-09 19:05:33 -07:00
// 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"
2020-02-11 17:31:56 -08:00
// sample mnemonic plugin
2021-04-23 13:06:53 -07:00
androidTestImplementation 'com.github.zcash:zcash-android-wallet-plugins:_'
androidTestImplementation 'cash.z.ecc.android:kotlin-bip39:_'
2018-11-20 23:01:45 -08:00
}
2018-11-20 23:04:53 -08:00
2021-04-09 16:50:59 -07:00
//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.
//}
2020-06-09 18:56:49 -07:00
defaultTasks 'ciBuild'
2021-03-10 10:10:03 -08:00
preBuild . dependsOn ( 'ktlintFormat' )
preBuild . dependsOn ( 'ktlint' )
2019-01-02 21:31:12 -08:00
preBuild . dependsOn includeDirBugFix
2021-03-10 10:10:03 -08:00
2021-04-09 16:50:59 -07:00
//check.dependsOn dependencyCheckAggregate
2021-04-09 18:41:55 -07:00
def loadConfig ( fileName ) {
def config = new ConfigSlurper ( ) . parse ( file ( fileName ) . toURL ( ) )
project . ext . config = config
}