[#166] Included build for SDK development

Note that the SDK master branch contains breaking API changes, which the Secant app hasn't yet been updated to support, so enabling an included build will have compile failures.
This commit is contained in:
Carter Jernigan 2022-01-04 08:41:05 -05:00
parent ee96e915ae
commit eb550f680e
15 changed files with 37 additions and 10 deletions

View File

@ -78,7 +78,7 @@ android {
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
}
packagingOptions {

View File

@ -29,5 +29,3 @@ dependencyResolutionManagement {
}
}
}
rootProject.name = "build-conventions"

View File

@ -23,7 +23,7 @@ pluginManager.withPlugin("org.jetbrains.kotlin.multiplatform") {
targets.all {
compilations.all {
kotlinOptions {
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
}
}

View File

@ -35,7 +35,6 @@ Start by making sure the command line with Gradle works first, because **all the
## Troubleshooting
1. Verify that the Git repo has not been modified. Due to strict dependency locking (for security reasons), the build will fail unless the locks are also updated
1. If you
1. Try running from the command line instead of Android Studio, to rule out Android Studio issues. If it works from the command line, try this step to reset Android Studio
1. Quit Android Studio
2. Deleting the invisible `.idea` in the root directory of the project
@ -69,3 +68,19 @@ To enable release signing, a release keystore needs to be provided during the bu
* ZCASH_RELEASE_KEY_ALIAS_PASSWORD
On a developer machine, these might be set under the user's global properties (e.g. `~/.gradle/gradle.properties` on macOS and Linux). On a continuous integration machine, these can also be set using environment variables with the prefix `ORG_GRADLE_PROJECT_` (e.g. `ORG_GRADLE_PROJECT_ZCASH_RELEASE_KEYSTORE_PATH`). DO NOT set these in the gradle.properties inside the Git repository, as this will leak your keystore password.
### Included builds
To simplify implementation of SDK features in conjunction with changes to the app, a Gradle [Included Build](https://docs.gradle.org/current/userguide/composite_builds.html) can be configured.
1. Check out the SDK to a directory path of `../zcash-android-sdk` relative to the root of this app's repo. For example:
parent/
secant-android-wallet/
zcash-android-sdk/
1. Verify that the `zcash-android-sdk` builds correctly on its own
1. Build `secant-android-wallet`, setting the Gradle property `IS_SDK_INCLUDED_BUILD=true`
There are some limitations of included builds:
1. Properties from `secant-android-wallet` will override those set in `zcash-android-sdk` with the same name
1. Modules in each project cannot share the same name. For this reason, build-conventions have different names in each repo (`zcash-android-sdk/build-conventions` vs `secant-android-wallet/build-convention`)

View File

@ -12,7 +12,7 @@ android.nonTransitiveRClass=true
android.builder.sdkDownload=true
# Kotlin compiler warnings can be considered errors, failing the build.
IS_TREAT_WARNINGS_AS_ERRORS=true
ZCASH_IS_TREAT_WARNINGS_AS_ERRORS=true
# The app module will crash at launch when coverage is enabled, so coverage is only enabled explicitly for tests.
IS_COVERAGE_ENABLED=false
@ -48,6 +48,9 @@ ZCASH_GOOGLE_PLAY_SERVICE_KEY_FILE_PATH=
# Deploy commits the build on Google Play, creating a new release
ZCASH_GOOGLE_PLAY_DEPLOY_MODE=build
# Toggles between using the SDK Maven artifact versus an included build
IS_SDK_INCLUDED_BUILD=false
# Versions
ANDROID_MIN_SDK_VERSION=24
ANDROID_TARGET_SDK_VERSION=31

View File

@ -9,7 +9,7 @@ android {
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs = freeCompilerArgs + "-Xopt-in=kotlin.RequiresOptIn"
}

View File

@ -8,7 +8,7 @@ android {
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs = freeCompilerArgs.plus("-Xopt-in=kotlin.RequiresOptIn")
}
}

View File

@ -149,7 +149,7 @@ dependencyResolutionManagement {
rootProject.name = "zcash-android-app"
includeBuild("build-conventions")
includeBuild("build-convention")
include("app")
include("build-info-lib")
@ -157,3 +157,14 @@ include("preference-api-lib")
include("preference-impl-android-lib")
include("sdk-ext-lib")
include("ui-lib")
if (extra["IS_SDK_INCLUDED_BUILD"].toString().toBoolean()) {
// Currently assume the SDK is up one level with a hardcoded directory name
// If this becomes problematic, `IS_SDK_INCLUDED_BUILD` could be turned into a path
// instead.
includeBuild("../zcash-android-sdk") {
dependencySubstitution {
substitute(module("cash.z.ecc.android:zcash-android-sdk")).using(project(":sdk-lib"))
}
}
}

View File

@ -19,7 +19,7 @@ android {
// TODO [#6]: Figure out how to move this into the build-conventions
kotlinOptions {
jvmTarget = libs.versions.java.get()
allWarningsAsErrors = project.property("IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
allWarningsAsErrors = project.property("ZCASH_IS_TREAT_WARNINGS_AS_ERRORS").toString().toBoolean()
freeCompilerArgs = freeCompilerArgs.plus("-Xopt-in=kotlin.RequiresOptIn")
}