[#612] Make dependency locking configurable

This implementation is somewhat special from our other Gradle properties, because it does not get declared in the root gradle.properties.  The reason is that included builds are supposed to have their own properties e.g.

root_project/gradle.properties
root_project/build-conventions/gradle.properties

Instead of declaring the property in different places which might lead to confusion, this leaves the property undeclared, with the Gradle scripts assuming a default value of true.  The only time this is expected to be overridden is due to a workaround for an Android Studio bug.
This commit is contained in:
Carter Jernigan 2022-07-25 10:33:59 -04:00 committed by Carter Jernigan
parent 4a106c0498
commit 96eab807cb
4 changed files with 38 additions and 3 deletions

View File

@ -222,5 +222,6 @@ Publishing instructions for maintainers of this repository can be found in [PUBL
[Back to contents](#contents)
# Known Issues
1. Intel-based machines may have trouble building in Android Studio. The workaround is to add the following line to `~/.gradle/gradle.properties` `ZCASH_IS_DEPENDENCY_LOCKING_ENABLED=false`
1. During builds, a warning will be printed that says "Unable to detect AGP versions for included builds. All projects in the build should use the same AGP version." This can be safely ignored. The version under build-conventions is the same as the version used elsewhere in the application.
1. Android Studio will warn about the Gradle checksum. This is a [known issue](https://github.com/gradle/gradle/issues/9361) and can be safely ignored.

View File

@ -6,12 +6,34 @@ plugins {
buildscript {
dependencyLocking {
lockAllConfigurations()
// This property is treated specially, as it is not defined by default in the root gradle.properties
// and declaring it in the root gradle.properties is ignored by included builds. This only picks up
// a value declared as a system property, a command line argument, or a an environment variable.
val isDependencyLockingEnabled = if (project.hasProperty("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED")) {
project.property("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED").toString().toBoolean()
} else {
true
}
if (isDependencyLockingEnabled) {
lockAllConfigurations()
}
}
}
dependencyLocking {
lockAllConfigurations()
// This property is treated specially, as it is not defined by default in the root gradle.properties
// and declaring it in the root gradle.properties is ignored by included builds. This only picks up
// a value declared as a system property, a command line argument, or a an environment variable.
val isDependencyLockingEnabled = if (project.hasProperty("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED")) {
project.property("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED").toString().toBoolean()
} else {
true
}
if (isDependencyLockingEnabled) {
lockAllConfigurations()
}
}
// Per conversation in the KotlinLang Slack, Gradle uses Java 8 compatibility internally

View File

@ -1,6 +1,17 @@
//dependencyLocking {
// lockAllConfigurations()
// This property is treated specially, as it is not defined by default in the root gradle.properties
// and declaring it in the root gradle.properties is ignored by included builds. This only picks up
// a value declared as a system property, a command line argument, or a an environment variable.
// val isDependencyLockingEnabled = if (project.hasProperty("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED")) {
// project.property("ZCASH_IS_DEPENDENCY_LOCKING_ENABLED").toString().toBoolean()
// } else {
// true
// }
//
// if (isDependencyLockingEnabled) {
// lockAllConfigurations()
// }
//}
tasks {

View File

@ -68,6 +68,7 @@ Start by making sure the command line with Gradle works first, because **all the
1. Note: When first opening the project, Android Studio will warn that Gradle checksums are not fully supported. Choose the "Use checksum" option. This is a security feature that we have explicitly enabled.
1. Shortly after opening the project, Android Studio may prompt about updating the Android Gradle Plugin. DO NOT DO THIS. If you do so, the build will fail because the project also has dependency locking enabled as a security feature. To learn more, see [Build integrity.md](Build%20Integrity.md)
1. Android Studio may prompt about updating the Kotlin plugin. Do this. Our application often uses a newer version of Kotlin than is bundled with Android Studio.
1. Note that some versions of Android Studio on Intel machines have trouble with dependency locks. If you experience this issue, the workaround is to add the following line to `~/.gradle/gradle.properties` `ZCASH_IS_DEPENDENCY_LOCKING_ENABLED=false`
1. After Android Studio finishes syncing with Gradle, look for the green "play" run button in the toolbar. To the left of it, choose the "demo-app" run configuration under the dropdown menu. Then hit the run button.
1. Note: The SDK supports both testnet and mainnet. The decision to switch between them is made at the application level. To switch between build variants, look for "Build Variants" which is usually a small button in the left gutter of the Android Studio window.