2021-09-14 14:02:06 -07:00
|
|
|
plugins {
|
|
|
|
id("com.android.application")
|
|
|
|
kotlin("android")
|
|
|
|
id("kotlin-parcelize")
|
|
|
|
id("androidx.navigation.safeargs")
|
|
|
|
id("zcash.android-build-conventions")
|
2021-12-02 12:18:17 -08:00
|
|
|
id("com.github.triplet.play")
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
|
|
|
|
2021-10-09 07:36:58 -07:00
|
|
|
val packageName = "cash.z.ecc"
|
2021-09-14 14:02:06 -07:00
|
|
|
|
|
|
|
android {
|
|
|
|
defaultConfig {
|
|
|
|
applicationId = packageName
|
2021-12-02 12:18:17 -08:00
|
|
|
|
|
|
|
// If Google Play deployment is triggered, then these are placeholders which are overwritten
|
|
|
|
// when the deployment runs
|
|
|
|
versionCode = project.property("ZCASH_VERSION_CODE").toString().toInt()
|
|
|
|
versionName = project.property("ZCASH_VERSION_NAME").toString()
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
|
|
|
|
2021-11-09 10:53:20 -08:00
|
|
|
compileOptions {
|
|
|
|
isCoreLibraryDesugaringEnabled = true
|
|
|
|
}
|
|
|
|
|
2021-09-14 14:02:06 -07:00
|
|
|
flavorDimensions.add("network")
|
|
|
|
|
|
|
|
productFlavors {
|
|
|
|
// would rather name them "testnet" and "mainnet" but product flavor names cannot start with the word "test"
|
|
|
|
create("zcashtestnet") {
|
|
|
|
dimension = "network"
|
|
|
|
applicationId = "$packageName.testnet" // allow to be installed alongside mainnet
|
|
|
|
matchingFallbacks.addAll(listOf("zcashtestnet", "debug"))
|
|
|
|
}
|
|
|
|
|
|
|
|
create("zcashmainnet") {
|
|
|
|
dimension = "network"
|
|
|
|
applicationId = packageName
|
|
|
|
matchingFallbacks.addAll(listOf("zcashmainnet", "release"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buildTypes {
|
|
|
|
getByName("release").apply {
|
|
|
|
isMinifyEnabled = project.property("IS_MINIFY_ENABLED").toString().toBoolean()
|
2021-12-03 05:12:40 -08:00
|
|
|
isShrinkResources = project.property("IS_MINIFY_ENABLED").toString().toBoolean()
|
|
|
|
proguardFiles(
|
|
|
|
getDefaultProguardFile("proguard-android-optimize.txt"),
|
|
|
|
"proguard-project.txt"
|
2021-09-14 14:02:06 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signingConfigs {
|
|
|
|
val releaseKeystorePath = project.property("ZCASH_RELEASE_KEYSTORE_PATH").toString()
|
|
|
|
val releaseKeystorePassword = project.property("ZCASH_RELEASE_KEYSTORE_PASSWORD").toString()
|
|
|
|
val releaseKeyAlias = project.property("ZCASH_RELEASE_KEY_ALIAS").toString()
|
|
|
|
val releaseKeyAliasPassword =
|
|
|
|
project.property("ZCASH_RELEASE_KEY_ALIAS_PASSWORD").toString()
|
|
|
|
val isReleaseSigningConfigured = listOf(
|
|
|
|
releaseKeystorePath,
|
|
|
|
releaseKeystorePassword,
|
|
|
|
releaseKeyAlias,
|
|
|
|
releaseKeyAliasPassword
|
|
|
|
).all { !it.isNullOrBlank() }
|
|
|
|
|
|
|
|
if (isReleaseSigningConfigured) {
|
|
|
|
// If this block doesn't execute, the output will be unsigned
|
|
|
|
create("release").apply {
|
|
|
|
storeFile = File(releaseKeystorePath)
|
|
|
|
storePassword = releaseKeystorePassword
|
|
|
|
keyAlias = releaseKeyAlias
|
|
|
|
keyPassword = releaseKeyAliasPassword
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO [#6]: Figure out how to move this into the build-conventions
|
|
|
|
kotlinOptions {
|
|
|
|
jvmTarget = libs.versions.java.get()
|
2021-09-22 09:37:15 -07:00
|
|
|
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
2021-12-03 05:12:40 -08:00
|
|
|
|
|
|
|
packagingOptions {
|
|
|
|
resources.excludes.addAll(
|
|
|
|
listOf(
|
|
|
|
"**/*.kotlin_metadata",
|
|
|
|
".readme",
|
|
|
|
"build-data.properties",
|
|
|
|
"META-INF/*.kotlin_module",
|
|
|
|
"META-INF/android.arch**",
|
|
|
|
"META-INF/androidx**",
|
|
|
|
"META-INF/com.android**",
|
|
|
|
"META-INF/com.google.android.material_material.version",
|
|
|
|
"META-INF/com.google.dagger_dagger.version",
|
|
|
|
"META-INF/services/org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor",
|
|
|
|
"META-INF/services/org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar",
|
|
|
|
"META-INF/services/org.jetbrains.kotlin.diagnostics.rendering.DefaultErrorMessages\$Extension",
|
|
|
|
"firebase-**.properties",
|
|
|
|
"kotlin/**",
|
|
|
|
"play-services-**.properties",
|
|
|
|
"protolite-well-known-types.properties",
|
|
|
|
"transport-api.properties",
|
|
|
|
"transport-backend-cct.properties",
|
|
|
|
"transport-runtime.properties",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-11-09 10:53:20 -08:00
|
|
|
coreLibraryDesugaring(libs.desugaring)
|
|
|
|
|
2021-09-14 14:02:06 -07:00
|
|
|
implementation(libs.androidx.activity)
|
|
|
|
implementation(libs.androidx.annotation)
|
|
|
|
implementation(libs.androidx.core)
|
2021-11-12 04:09:30 -08:00
|
|
|
implementation(libs.kotlin.stdlib)
|
2021-09-14 14:02:06 -07:00
|
|
|
implementation(libs.kotlinx.coroutines.android)
|
|
|
|
implementation(libs.kotlinx.coroutines.core)
|
2021-10-09 07:36:58 -07:00
|
|
|
implementation(projects.uiLib)
|
2021-09-14 14:02:06 -07:00
|
|
|
|
|
|
|
androidTestImplementation(libs.bundles.androidx.test)
|
2021-10-11 12:52:24 -07:00
|
|
|
|
|
|
|
if (project.property("IS_USE_TEST_ORCHESTRATOR").toString().toBoolean()) {
|
|
|
|
androidTestUtil(libs.androidx.test.orchestrator) {
|
|
|
|
artifact {
|
|
|
|
type = "apk"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-14 14:02:06 -07:00
|
|
|
}
|
2021-12-02 12:18:17 -08:00
|
|
|
|
|
|
|
val googlePlayServiceKeyFilePath = project.property("ZCASH_GOOGLE_PLAY_SERVICE_KEY_FILE_PATH").toString()
|
|
|
|
if (googlePlayServiceKeyFilePath.isNotEmpty()) {
|
|
|
|
// Update the versionName to reflect bumps in versionCode
|
|
|
|
androidComponents {
|
|
|
|
val versionCodeOffset = 0 // Change this to zero the final digit of the versionName
|
|
|
|
onVariants { variant ->
|
|
|
|
for (output in variant.outputs) {
|
|
|
|
val processedVersionCode = output.versionCode.map { playVersionCode ->
|
|
|
|
val defaultVersionName = project.property("ZCASH_VERSION_NAME").toString()
|
|
|
|
// Version names will look like `myCustomVersionName.123`
|
|
|
|
playVersionCode?.let {
|
|
|
|
val delta = it - versionCodeOffset
|
|
|
|
if (delta < 0) {
|
|
|
|
defaultVersionName
|
|
|
|
} else {
|
|
|
|
"$defaultVersionName.$delta"
|
|
|
|
}
|
|
|
|
} ?: defaultVersionName
|
|
|
|
}
|
|
|
|
|
|
|
|
output.versionName.set(processedVersionCode)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
configure<com.github.triplet.gradle.play.PlayPublisherExtension> {
|
|
|
|
serviceAccountCredentials.set(File(googlePlayServiceKeyFilePath))
|
|
|
|
|
|
|
|
// For safety, only allow deployment to internal testing track
|
|
|
|
track.set("internal")
|
|
|
|
|
|
|
|
// Automatically manage version incrementing
|
|
|
|
resolutionStrategy.set(com.github.triplet.gradle.androidpublisher.ResolutionStrategy.AUTO)
|
|
|
|
|
|
|
|
val deployMode = project.property("ZCASH_GOOGLE_PLAY_DEPLOY_MODE").toString()
|
|
|
|
if ("build" == deployMode) {
|
|
|
|
releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.DRAFT)
|
|
|
|
// Prevent upload; only generates a build with the correct version number
|
|
|
|
commit.set(false)
|
|
|
|
} else if ("deploy" == deployMode) {
|
|
|
|
releaseStatus.set(com.github.triplet.gradle.androidpublisher.ReleaseStatus.COMPLETED)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|