build.gradle 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. plugins {
  2. id 'org.sonarqube'
  3. }
  4. apply plugin: 'com.android.application'
  5. apply plugin: 'kotlin-android'
  6. apply plugin: 'kotlin-kapt'
  7. // only apply the plugin if we are dealing with a AppGallery build
  8. if (getGradle().getStartParameter().getTaskRequests().toString().contains("Hms")) {
  9. println "enabling hms plugin"
  10. apply plugin: 'com.huawei.agconnect'
  11. }
  12. // version codes
  13. def app_version = "4.8"
  14. def beta_suffix = "" // with leading dash
  15. /**
  16. * Return the git hash, if git is installed.
  17. */
  18. def getGitHash = { ->
  19. def stdout = new ByteArrayOutputStream()
  20. def stderr = new ByteArrayOutputStream()
  21. try {
  22. exec {
  23. commandLine 'git', 'rev-parse', '--short', 'HEAD'
  24. standardOutput = stdout
  25. errorOutput = stderr
  26. ignoreExitValue true
  27. }
  28. } catch (ignored) { /* If git binary is not found, carry on */ }
  29. def hash = stdout.toString().trim()
  30. return (hash.isEmpty()) ? "?" : hash
  31. }
  32. /**
  33. * Look up the keystore with the specified name in a `keystore` directory
  34. * adjacent to this project directory. If it exists, return a signing config.
  35. * Otherwise, return null.
  36. */
  37. def findKeystore = { name ->
  38. def basePath = "${projectDir.getAbsolutePath()}/../../keystore"
  39. def storePath = "${basePath}/${name}.keystore"
  40. def storeFile = new File(storePath)
  41. if (storeFile.exists() && storeFile.isFile()) {
  42. def propertiesPath = "${basePath}/${name}.properties"
  43. def propertiesFile = new File(propertiesPath)
  44. if (propertiesFile.exists() && propertiesFile.isFile()) {
  45. Properties props = new Properties()
  46. propertiesFile.withInputStream { props.load(it) }
  47. return [
  48. storeFile: storePath,
  49. storePassword: props.storePassword,
  50. keyAlias: props.keyAlias,
  51. keyPassword: props.keyPassword,
  52. ]
  53. } else {
  54. return [
  55. storeFile: storePath,
  56. storePassword: null,
  57. keyAlias: null,
  58. keyPassword: null,
  59. ]
  60. }
  61. }
  62. }
  63. /**
  64. * Map with keystore paths (if found).
  65. */
  66. def keystores = [
  67. debug: findKeystore("debug"),
  68. release: findKeystore("threema"),
  69. hms_release: findKeystore("threema_hms"),
  70. onprem_release: findKeystore("onprem"),
  71. red_release: findKeystore("red"),
  72. fdroid_release: findKeystore("threema_fdroid"),
  73. ]
  74. android {
  75. // NOTE: When adjusting compileSdkVersion, buildToolsVersion or ndkVersion,
  76. // make sure to adjust them in `scripts/Dockerfile` and
  77. // `.gitlab-ci.yml` as well!
  78. compileSdkVersion 31
  79. buildToolsVersion '31.0.0'
  80. ndkVersion '21.1.6352462'
  81. defaultConfig {
  82. minSdkVersion 21
  83. //noinspection OldTargetApi
  84. targetSdkVersion 30
  85. vectorDrawables.useSupportLibrary = true
  86. applicationId "ch.threema.app"
  87. testApplicationId 'ch.threema.app.test'
  88. versionCode 743
  89. versionName "${app_version}${beta_suffix}"
  90. resValue "string", "app_name", "Threema"
  91. // package name used for sync adapter - needs to match mime types below
  92. resValue "string", "package_name", applicationId
  93. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.profile"
  94. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.call"
  95. buildConfigField "int", "MAX_GROUP_SIZE", "256"
  96. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"g-\""
  97. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.g-\""
  98. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.threema.ch\""
  99. buildConfigField "int[]", "CHAT_SERVER_PORTS", "{5222, 443}"
  100. buildConfigField "String", "MEDIA_PATH", "\"Threema\""
  101. buildConfigField "boolean", "CHAT_SERVER_GROUPS", "true"
  102. buildConfigField "boolean", "DISABLE_CERT_PINNING", "false"
  103. buildConfigField "boolean", "VIDEO_CALLS_ENABLED", "true"
  104. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x45, (byte) 0x0b, (byte) 0x97, (byte) 0x57, (byte) 0x35, (byte) 0x27, (byte) 0x9f, (byte) 0xde, (byte) 0xcb, (byte) 0x33, (byte) 0x13, (byte) 0x64, (byte) 0x8f, (byte) 0x5f, (byte) 0xc6, (byte) 0xee, (byte) 0x9f, (byte) 0xf4, (byte) 0x36, (byte) 0x0e, (byte) 0xa9, (byte) 0x2a, (byte) 0x8c, (byte) 0x17, (byte) 0x51, (byte) 0xc6, (byte) 0x61, (byte) 0xe4, (byte) 0xc0, (byte) 0xd8, (byte) 0xc9, (byte) 0x09 }"
  105. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0xda, (byte) 0x7c, (byte) 0x73, (byte) 0x79, (byte) 0x8f, (byte) 0x97, (byte) 0xd5, (byte) 0x87, (byte) 0xc3, (byte) 0xa2, (byte) 0x5e, (byte) 0xbe, (byte) 0x0a, (byte) 0x91, (byte) 0x41, (byte) 0x7f, (byte) 0x76, (byte) 0xdb, (byte) 0xcc, (byte) 0xcd, (byte) 0xda, (byte) 0x29, (byte) 0x30, (byte) 0xe6, (byte) 0xa9, (byte) 0x09, (byte) 0x0a, (byte) 0xf6, (byte) 0x2e, (byte) 0xba, (byte) 0x6f, (byte) 0x15 }"
  106. buildConfigField "String", "GIT_HASH", "\"${getGitHash()}\""
  107. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.threema.ch/\""
  108. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.threema.ch/\""
  109. buildConfigField "String", "WORK_SERVER_URL", "null"
  110. buildConfigField "String", "WORK_SERVER_IPV6_URL", "null"
  111. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_URL", "\"https://blobp-{blobIdPrefix}.threema.ch/{blobId}\""
  112. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_IPV6_URL", "\"https://ds-blobp-{blobIdPrefix}.threema.ch/{blobId}\""
  113. buildConfigField "String", "BLOB_SERVER_DONE_URL", "\"https://blobp-{blobIdPrefix}.threema.ch/{blobId}/done\""
  114. buildConfigField "String", "BLOB_SERVER_DONE_IPV6_URL", "\"https://ds-blobp-{blobIdPrefix}.threema.ch/{blobId}/done\""
  115. buildConfigField "String", "BLOB_SERVER_UPLOAD_URL", "\"https://blobp-upload.threema.ch/upload\""
  116. buildConfigField "String", "BLOB_SERVER_UPLOAD_IPV6_URL", "\"https://ds-blobp-upload.threema.ch/upload\""
  117. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.threema.ch/\""
  118. buildConfigField "String", "SAFE_SERVER_URL", "\"https://safe-%h.threema.ch/\""
  119. buildConfigField "String", "WEB_SERVER_URL", "\"https://web.threema.ch/\""
  120. buildConfigField "String", "ONPREM_ID_PREFIX", "\"O\""
  121. buildConfigField "String", "LOG_TAG", "\"3ma\""
  122. buildConfigField "String[]", "ONPREM_CONFIG_TRUSTED_PUBLIC_KEYS", "null"
  123. buildConfigField "boolean", "SEND_CONSUMED_DELIVERY_RECEIPTS", "false"
  124. // config fields for action URLs / deep links
  125. buildConfigField "String", "uriScheme", "\"threema\""
  126. buildConfigField "String", "actionUrl", "\"go.threema.ch\""
  127. buildConfigField "String", "contactActionUrl", "\"threema.id\""
  128. buildConfigField "String", "groupLinkActionUrl", "\"threema.group\""
  129. // duplicated for manifest
  130. manifestPlaceholders = [
  131. uriScheme: "threema",
  132. contactActionUrl: "threema.id",
  133. groupLinkActionUrl: "threema.group",
  134. actionUrl: "go.threema.ch"
  135. ]
  136. ndk {
  137. abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
  138. }
  139. testInstrumentationRunner 'ch.threema.app.ThreemaTestRunner'
  140. testInstrumentationRunnerArgument 'notAnnotation', 'ch.threema.app.TestFastlaneOnly,ch.threema.app.DangerousTest'
  141. testInstrumentationRunnerArgument 'disableAnalytics', 'true' // https://developer.android.com/training/testing/espresso/setup#analytics
  142. }
  143. splits {
  144. abi {
  145. enable true
  146. reset()
  147. include 'armeabi-v7a', 'x86', "arm64-v8a", "x86_64"
  148. exclude 'armeabi', 'mips', 'mips64'
  149. universalApk true
  150. }
  151. }
  152. // Assign different version code for each output
  153. project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
  154. android.applicationVariants.all { variant ->
  155. variant.outputs.each { output ->
  156. output.versionCodeOverride =
  157. project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI), 0) * 1000000 + android.defaultConfig.versionCode
  158. }
  159. }
  160. flavorDimensions "default"
  161. productFlavors {
  162. none { }
  163. store_google { }
  164. store_threema {
  165. resValue "string", "shop_download_filename", "Threema-update.apk"
  166. }
  167. store_google_work {
  168. versionName "${app_version}k${beta_suffix}"
  169. applicationId "ch.threema.app.work"
  170. testApplicationId 'ch.threema.app.work.test'
  171. resValue "string", "app_name", "Threema Work"
  172. resValue "string", "package_name", applicationId
  173. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.profile"
  174. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.call"
  175. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  176. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  177. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWork\""
  178. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.threema.ch/\""
  179. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.threema.ch/\""
  180. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  181. // config fields for action URLs / deep links
  182. buildConfigField "String", "uriScheme", "\"threemawork\""
  183. buildConfigField "String", "actionUrl", "\"work.threema.ch\""
  184. manifestPlaceholders = [
  185. uriScheme: "threemawork",
  186. actionUrl: "work.threema.ch",
  187. ]
  188. }
  189. sandbox {
  190. applicationId "ch.threema.app.sandbox"
  191. testApplicationId 'ch.threema.app.sandbox.test'
  192. resValue "string", "app_name", "Threema Sandbox"
  193. resValue "string", "package_name", applicationId
  194. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.profile"
  195. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.call"
  196. buildConfigField "String", "MEDIA_PATH", "\"ThreemaSandbox\""
  197. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  198. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  199. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  200. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  201. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  202. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  203. }
  204. sandbox_work {
  205. versionName "${app_version}k${beta_suffix}"
  206. applicationId "ch.threema.app.sandbox.work"
  207. testApplicationId 'ch.threema.app.sandbox.work.test'
  208. resValue "string", "app_name", "Threema Sandbox Work"
  209. resValue "string", "package_name", applicationId
  210. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.work.profile"
  211. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.sandbox.work.call"
  212. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  213. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  214. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  215. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWorkSandbox\""
  216. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  217. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  218. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  219. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  220. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.test.threema.ch/\""
  221. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.test.threema.ch/\""
  222. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  223. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  224. // config fields for action URLs / deep links
  225. buildConfigField "String", "uriScheme", "\"threemawork\""
  226. buildConfigField "String", "actionUrl", "\"work.threema.ch\""
  227. manifestPlaceholders = [
  228. uriScheme : "threemawork",
  229. actionUrl : "work.threema.ch",
  230. ]
  231. }
  232. onprem {
  233. versionName "${app_version}o${beta_suffix}"
  234. applicationId "ch.threema.app.onprem"
  235. testApplicationId 'ch.threema.app.onprem.test'
  236. resValue "string", "app_name", "Threema OnPrem"
  237. resValue "string", "package_name", applicationId
  238. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.profile"
  239. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.onprem.call"
  240. buildConfigField "int", "MAX_GROUP_SIZE", "256"
  241. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"\""
  242. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"\""
  243. buildConfigField "String", "CHAT_SERVER_SUFFIX", "null"
  244. buildConfigField "String", "MEDIA_PATH", "\"ThreemaOnPrem\""
  245. buildConfigField "boolean", "CHAT_SERVER_GROUPS", "false"
  246. buildConfigField "byte[]", "SERVER_PUBKEY", "null"
  247. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "null"
  248. buildConfigField "String", "DIRECTORY_SERVER_URL", "null"
  249. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "null"
  250. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_URL", "null"
  251. buildConfigField "String", "BLOB_SERVER_DOWNLOAD_IPV6_URL", "null"
  252. buildConfigField "String", "BLOB_SERVER_DONE_URL", "null"
  253. buildConfigField "String", "BLOB_SERVER_DONE_IPV6_URL", "null"
  254. buildConfigField "String", "BLOB_SERVER_UPLOAD_URL", "null"
  255. buildConfigField "String", "BLOB_SERVER_UPLOAD_IPV6_URL", "null"
  256. buildConfigField "String[]", "ONPREM_CONFIG_TRUSTED_PUBLIC_KEYS", "new String[] {\"ek1qBp4DyRmLL9J5sCmsKSfwbsiGNB4veDAODjkwe/k=\", \"Hrk8aCjwKkXySubI7CZ3y9Sx+oToEHjNkGw98WSRneU=\", \"5pEn1T/5bhecNWrp9NgUQweRfgVtu/I8gRb3VxGP7k4=\"}"
  257. buildConfigField "String", "LOG_TAG", "\"3maop\""
  258. // config fields for action URLs / deep links
  259. buildConfigField "String", "uriScheme", "\"threemaonprem\""
  260. buildConfigField "String", "actionUrl", "\"onprem.threema.ch\""
  261. manifestPlaceholders = [
  262. uriScheme: "threemaonprem",
  263. actionUrl: "onprem.threema.ch",
  264. ]
  265. }
  266. red { // Essentially like sandbox work, but with a different icon and accent color, used for internal testing
  267. versionName "${app_version}r${beta_suffix}"
  268. applicationId "ch.threema.app.red"
  269. testApplicationId 'ch.threema.app.red.test'
  270. resValue "string", "app_name", "Threema Red"
  271. resValue "string", "package_name", applicationId
  272. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.red.profile"
  273. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.red.call"
  274. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  275. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  276. buildConfigField "String", "CHAT_SERVER_SUFFIX", "\".0.test.threema.ch\""
  277. buildConfigField "String", "MEDIA_PATH", "\"ThreemaRed\""
  278. buildConfigField "byte[]", "SERVER_PUBKEY", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  279. buildConfigField "byte[]", "SERVER_PUBKEY_ALT", "new byte[] {(byte) 0x5a, (byte) 0x98, (byte) 0xf2, (byte) 0x3d, (byte) 0xe6, (byte) 0x56, (byte) 0x05, (byte) 0xd0, (byte) 0x50, (byte) 0xdc, (byte) 0x00, (byte) 0x64, (byte) 0xbe, (byte) 0x07, (byte) 0xdd, (byte) 0xdd, (byte) 0x81, (byte) 0x1d, (byte) 0xa1, (byte) 0x16, (byte) 0xa5, (byte) 0x43, (byte) 0xce, (byte) 0x43, (byte) 0xaa, (byte) 0x26, (byte) 0x87, (byte) 0xd1, (byte) 0x9f, (byte) 0x20, (byte) 0xaf, (byte) 0x3c }"
  280. buildConfigField "String", "DIRECTORY_SERVER_URL", "\"https://apip.test.threema.ch/\""
  281. buildConfigField "String", "DIRECTORY_SERVER_IPV6_URL", "\"https://ds-apip.test.threema.ch/\""
  282. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.test.threema.ch/\""
  283. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.test.threema.ch/\""
  284. buildConfigField "String", "AVATAR_FETCH_URL", "\"https://avatar.test.threema.ch/\""
  285. buildConfigField "String", "LOG_TAG", "\"3mared\""
  286. buildConfigField "boolean", "SEND_CONSUMED_DELIVERY_RECEIPTS", "true"
  287. // config fields for action URLs / deep links
  288. buildConfigField "String", "uriScheme", "\"threemared\""
  289. buildConfigField "String", "actionUrl", "\"red.threema.ch\""
  290. manifestPlaceholders = [
  291. uriScheme: "threemared",
  292. actionUrl: "red.threema.ch",
  293. ]
  294. }
  295. hms {
  296. applicationId "ch.threema.app.hms"
  297. }
  298. hms_work {
  299. versionName "${app_version}k${beta_suffix}"
  300. applicationId "ch.threema.app.work.hms"
  301. testApplicationId 'ch.threema.app.work.test.hms'
  302. resValue "string", "app_name", "Threema Work"
  303. resValue "string", "package_name", "ch.threema.app.work"
  304. resValue "string", "contacts_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.profile"
  305. resValue "string", "call_mime_type", "vnd.android.cursor.item/vnd.ch.threema.app.work.call"
  306. buildConfigField "String", "CHAT_SERVER_PREFIX", "\"w-\""
  307. buildConfigField "String", "CHAT_SERVER_IPV6_PREFIX", "\"ds.w-\""
  308. buildConfigField "String", "MEDIA_PATH", "\"ThreemaWork\""
  309. buildConfigField "String", "WORK_SERVER_URL", "\"https://apip-work.threema.ch/\""
  310. buildConfigField "String", "WORK_SERVER_IPV6_URL", "\"https://ds-apip-work.threema.ch/\""
  311. buildConfigField "String", "LOG_TAG", "\"3mawrk\""
  312. // config fields for action URLs / deep links
  313. buildConfigField "String", "uriScheme", "\"threemawork\""
  314. buildConfigField "String", "actionUrl", "\"work.threema.ch\""
  315. manifestPlaceholders = [
  316. uriScheme: "threemawork",
  317. actionUrl: "work.threema.ch",
  318. ]
  319. }
  320. fdroid {
  321. versionName "${app_version}f${beta_suffix}"
  322. applicationId "ch.threema.app.fdroid"
  323. testApplicationId 'ch.threema.app.fdroid.test'
  324. resValue "string", "app_name", "Threema Libre"
  325. buildConfigField "String", "MEDIA_PATH", "\"ThreemaLibre\""
  326. }
  327. }
  328. signingConfigs {
  329. // Debug config
  330. if (keystores.debug != null) {
  331. debug {
  332. storeFile file(keystores.debug.storeFile)
  333. }
  334. } else {
  335. logger.warn("No debug keystore found. Falling back to locally generated keystore.")
  336. }
  337. // Release config
  338. if (keystores.release != null) {
  339. release {
  340. storeFile file(keystores.release.storeFile)
  341. storePassword keystores.release.storePassword
  342. keyAlias keystores.release.keyAlias
  343. keyPassword keystores.release.keyPassword
  344. }
  345. } else {
  346. logger.warn("No release keystore found. Falling back to locally generated keystore.")
  347. }
  348. // Release config
  349. if (keystores.hms_release != null) {
  350. hms_release {
  351. storeFile file(keystores.hms_release.storeFile)
  352. storePassword keystores.hms_release.storePassword
  353. keyAlias keystores.hms_release.keyAlias
  354. keyPassword keystores.hms_release.keyPassword
  355. }
  356. } else {
  357. logger.warn("No hms keystore found. Falling back to locally generated keystore.")
  358. }
  359. // Onprem release config
  360. if (keystores.onprem_release != null) {
  361. onprem_release {
  362. storeFile file(keystores.onprem_release.storeFile)
  363. storePassword keystores.onprem_release.storePassword
  364. keyAlias keystores.onprem_release.keyAlias
  365. keyPassword keystores.onprem_release.keyPassword
  366. }
  367. } else {
  368. logger.warn("No onprem keystore found. Falling back to locally generated keystore.")
  369. }
  370. // Red release config
  371. if (keystores.red_release != null) {
  372. red_release {
  373. storeFile file(keystores.red_release.storeFile)
  374. storePassword keystores.red_release.storePassword
  375. keyAlias keystores.red_release.keyAlias
  376. keyPassword keystores.red_release.keyPassword
  377. }
  378. } else {
  379. logger.warn("No red keystore found. Falling back to locally generated keystore.")
  380. }
  381. // F-Droid release config
  382. if (keystores.fdroid_release != null) {
  383. fdroid_release {
  384. storeFile file(keystores.fdroid_release.storeFile)
  385. storePassword keystores.fdroid_release.storePassword
  386. keyAlias keystores.fdroid_release.keyAlias
  387. keyPassword keystores.fdroid_release.keyPassword
  388. }
  389. } else {
  390. logger.warn("No fdroid keystore found. Falling back to locally generated keystore.")
  391. }
  392. }
  393. sourceSets {
  394. main {
  395. assets.srcDirs = ['assets']
  396. jniLibs.srcDirs = ['libs']
  397. }
  398. // Based on Google services
  399. none {
  400. java.srcDir 'src/google_services_based/java'
  401. }
  402. store_google {
  403. java.srcDir 'src/google_services_based/java'
  404. }
  405. store_google_work {
  406. java.srcDir 'src/google_services_based/java'
  407. }
  408. store_threema {
  409. java.srcDir 'src/google_services_based/java'
  410. }
  411. fdroid {
  412. assets.srcDirs = ['src/foss_based/assets']
  413. java.srcDir 'src/foss_based/java'
  414. }
  415. onprem {
  416. java.srcDir 'src/google_services_based/java'
  417. }
  418. sandbox {
  419. java.srcDir 'src/google_services_based/java'
  420. manifest.srcFile 'src/store_google/AndroidManifest.xml'
  421. }
  422. sandbox_work {
  423. java.srcDirs = ['src/store_google_work/java', 'src/google_services_based/java']
  424. res.srcDir 'src/store_google_work/res'
  425. manifest.srcFile 'src/store_google_work/AndroidManifest.xml'
  426. }
  427. red {
  428. java.srcDir 'src/google_services_based/java'
  429. res.srcDir 'src/red/res'
  430. }
  431. // Based on Huawei services
  432. hms {
  433. java.srcDir 'src/hms_services_based/java'
  434. }
  435. hms_work {
  436. java.srcDir 'src/hms_services_based/java'
  437. res.srcDir 'src/store_google_work/res'
  438. }
  439. // FOSS, no proprietary services
  440. fdroid {
  441. assets.srcDirs = ['src/foss_based/assets']
  442. java.srcDir 'src/foss_based/java'
  443. }
  444. }
  445. buildTypes {
  446. debug {
  447. debuggable true
  448. jniDebuggable false
  449. multiDexEnabled true
  450. multiDexKeepProguard file('multidex-keep.pro')
  451. testCoverageEnabled false
  452. if (keystores['debug'] != null) {
  453. signingConfig signingConfigs.debug
  454. }
  455. }
  456. release {
  457. debuggable false
  458. jniDebuggable false
  459. minifyEnabled true
  460. shrinkResources false // Caused inconsistencies between local and CI builds
  461. zipAlignEnabled true
  462. multiDexEnabled true
  463. multiDexKeepProguard file('multidex-keep.pro')
  464. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
  465. if (keystores['release'] != null) {
  466. productFlavors.store_google.signingConfig signingConfigs.release
  467. productFlavors.store_google_work.signingConfig signingConfigs.release
  468. productFlavors.store_threema.signingConfig signingConfigs.release
  469. productFlavors.sandbox.signingConfig signingConfigs.release
  470. productFlavors.sandbox_work.signingConfig signingConfigs.release
  471. productFlavors.none.signingConfig signingConfigs.release
  472. }
  473. if (keystores['hms_release'] != null) {
  474. productFlavors.hms.signingConfig signingConfigs.hms_release
  475. productFlavors.hms_work.signingConfig signingConfigs.hms_release
  476. }
  477. if (keystores['onprem_release'] != null) {
  478. productFlavors.onprem.signingConfig signingConfigs.onprem_release
  479. }
  480. if (keystores['red_release'] != null) {
  481. productFlavors.red.signingConfig signingConfigs.red_release
  482. }
  483. if (keystores['fdroid_release'] != null) {
  484. productFlavors.fdroid.signingConfig signingConfigs.fdroid_release
  485. }
  486. }
  487. }
  488. // Only build relevant buildType / flavor combinations
  489. variantFilter { variant ->
  490. def names = variant.flavors*.name
  491. if (
  492. variant.buildType.name == "release" && (
  493. names.contains("sandbox") || names.contains("sandbox_work")
  494. )
  495. ) {
  496. setIgnore(true)
  497. }
  498. }
  499. externalNativeBuild {
  500. ndkBuild {
  501. path 'jni/Android.mk'
  502. }
  503. }
  504. lintOptions {
  505. // set to true to have all release builds run lint on issues with severity=fatal
  506. // and abort the build (controlled by abortOnError above) if fatal issues are found
  507. checkReleaseBuilds true
  508. // check dependencies
  509. checkDependencies true
  510. // set to true to turn off analysis progress reporting by lint
  511. // quiet true
  512. // if true, stop the gradle build if errors are found
  513. abortOnError true
  514. // if true, only report errors
  515. ignoreWarnings false
  516. // if true, emit full/absolute paths to files with errors (true by default)
  517. //absolutePaths true
  518. // if true, check all issues, including those that are off by default
  519. checkAllWarnings true
  520. // if true, treat all warnings as errors
  521. warningsAsErrors false
  522. // turn off checking the given issue id's
  523. disable 'TypographyFractions', 'TypographyQuotes'
  524. // turn on the given issue id's
  525. disable 'RtlHardcoded', 'RtlCompat', 'RtlEnabled'
  526. // check *only* the given issue id's
  527. // check 'NewApi', 'InlinedApi'
  528. // if true, don't include source code lines in the error output
  529. noLines false
  530. // if true, show all locations for an error, do not truncate lists, etc.
  531. showAll true
  532. // if true, generate an XML report for use by for example Jenkins
  533. xmlReport true
  534. // file to write report to (if not specified, defaults to lint-results.xml)
  535. xmlOutput file("lint-report.xml")
  536. // Set the severity of the given issues to fatal (which means they will be
  537. // checked during release builds (even if the lint target is not included)
  538. fatal 'NewApi', 'InlinedApi'
  539. // Set the severity of the given issues to error
  540. error 'Wakelock', 'TextViewEdits', 'ResourceAsColor'
  541. // Set the severity of the given issues to warning
  542. warning 'MissingTranslation'
  543. // Set the severity of the given issues to ignore (same as disabling the check)
  544. ignore 'TypographyQuotes'
  545. }
  546. packagingOptions {
  547. exclude 'META-INF/DEPENDENCIES.txt'
  548. exclude 'META-INF/LICENSE.txt'
  549. exclude 'META-INF/NOTICE.txt'
  550. exclude 'META-INF/NOTICE'
  551. exclude 'META-INF/LICENSE'
  552. exclude 'META-INF/DEPENDENCIES'
  553. exclude 'META-INF/notice.txt'
  554. exclude 'META-INF/license.txt'
  555. exclude 'META-INF/dependencies.txt'
  556. exclude 'META-INF/LGPL2.1'
  557. exclude '**/*.proto'
  558. // fix https://stackoverflow.com/questions/42739916/aarch64-linux-android-strip-file-missing
  559. doNotStrip '*/mips/*.so'
  560. doNotStrip '*/mips64/*.so'
  561. doNotStrip '*/armeabi/*.so'
  562. }
  563. testOptions {
  564. // Disable animations in instrumentation tests
  565. animationsDisabled true
  566. unitTests {
  567. all {
  568. // All the usual Gradle options.
  569. testLogging {
  570. events "passed", "skipped", "failed", "standardOut", "standardError"
  571. outputs.upToDateWhen { false }
  572. exceptionFormat = 'full'
  573. }
  574. }
  575. // By default, local unit tests throw an exception any time the code you are testing tries to access
  576. // Android platform APIs (unless you mock Android dependencies yourself or with a testing
  577. // framework like Mockito). However, you can enable the following property so that the test
  578. // returns either null or zero when accessing platform APIs, rather than throwing an exception.
  579. returnDefaultValues true
  580. }
  581. }
  582. compileOptions {
  583. sourceCompatibility JavaVersion.VERSION_11
  584. targetCompatibility JavaVersion.VERSION_11
  585. }
  586. kotlin {
  587. jvmToolchain {
  588. languageVersion.set(JavaLanguageVersion.of(11))
  589. }
  590. }
  591. aaptOptions {
  592. noCompress 'png'
  593. }
  594. }
  595. dependencies {
  596. configurations.all {
  597. // Prefer modules that are part of this build (multi-project or composite build)
  598. // over external modules
  599. resolutionStrategy.preferProjectModules()
  600. // Alternatively, we can fail eagerly on version conflict to see the conflicts
  601. //resolutionStrategy.failOnVersionConflict()
  602. }
  603. implementation project(':domain')
  604. implementation 'net.zetetic:android-database-sqlcipher:4.5.1'
  605. implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
  606. implementation 'net.sf.opencsv:opencsv:2.3'
  607. implementation 'net.lingala.zip4j:zip4j:2.9.1'
  608. implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'
  609. implementation 'org.maplibre.gl:android-sdk:9.5.2'
  610. // commons-io >2.6 requires android 8
  611. implementation 'commons-io:commons-io:2.6'
  612. implementation "org.slf4j:slf4j-api:$slf4j_version"
  613. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'
  614. implementation 'com.github.CanHub:Android-Image-Cropper:4.1.0'
  615. implementation 'com.datatheorem.android.trustkit:trustkit:1.1.5'
  616. implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
  617. implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
  618. // AndroidX / Jetpack support libraries
  619. implementation "androidx.core:core-ktx:1.7.0"
  620. implementation "androidx.preference:preference-ktx:1.2.0"
  621. implementation 'androidx.recyclerview:recyclerview:1.2.1'
  622. implementation 'androidx.palette:palette-ktx:1.0.0'
  623. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
  624. implementation 'androidx.appcompat:appcompat:1.4.1'
  625. implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
  626. implementation 'androidx.biometric:biometric:1.1.0'
  627. implementation "androidx.work:work-runtime:2.7.1"
  628. implementation 'androidx.fragment:fragment-ktx:1.4.1'
  629. implementation 'androidx.activity:activity-ktx:1.4.0'
  630. implementation 'androidx.sqlite:sqlite:2.1.0'
  631. implementation "androidx.concurrent:concurrent-futures:1.1.0"
  632. implementation "androidx.camera:camera-camera2:1.1.0-rc01"
  633. implementation "androidx.camera:camera-lifecycle:1.1.0-rc01"
  634. implementation "androidx.camera:camera-view:1.1.0-rc01"
  635. implementation 'androidx.multidex:multidex:2.0.1'
  636. implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1"
  637. implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.1"
  638. implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"
  639. implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.4.1"
  640. implementation "androidx.lifecycle:lifecycle-service:2.4.1"
  641. implementation "androidx.lifecycle:lifecycle-process:2.4.1"
  642. implementation "androidx.lifecycle:lifecycle-common-java8:2.4.1"
  643. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
  644. implementation "androidx.paging:paging-runtime:3.1.1"
  645. implementation "androidx.sharetarget:sharetarget:1.1.0"
  646. implementation 'androidx.room:room-runtime:2.4.2'
  647. kapt 'androidx.room:room-compiler:2.4.2'
  648. implementation 'com.google.android.material:material:1.5.0'
  649. implementation 'com.google.android.exoplayer:exoplayer-core:2.17.1'
  650. implementation 'com.google.android.exoplayer:exoplayer-ui:2.17.1'
  651. implementation 'com.google.zxing:core:3.3.3' // zxing 3.4 crashes on API < 24
  652. implementation 'com.googlecode.libphonenumber:libphonenumber:8.12.45' // make sure to update this in domain's build.gradle as well
  653. // webclient dependencies
  654. implementation 'org.msgpack:msgpack-core:0.8.24!!'
  655. implementation 'com.neovisionaries:nv-websocket-client:2.9'
  656. // Backport of Streams and CompletableFuture. Remove once API level 24 is supported.
  657. implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.2'
  658. implementation('org.saltyrtc:saltyrtc-client:0.14.2') {
  659. exclude group: 'org.json'
  660. }
  661. implementation 'org.saltyrtc:chunked-dc:1.0.1'
  662. implementation 'ch.threema:webrtc-android:100.0.0'
  663. implementation('org.saltyrtc:saltyrtc-task-webrtc:0.18.1') {
  664. exclude module: 'saltyrtc-client'
  665. }
  666. // Glide components
  667. implementation 'com.github.bumptech.glide:glide:4.13.2'
  668. kapt 'com.github.bumptech.glide:compiler:4.13.2'
  669. // kotlin
  670. implementation "androidx.core:core-ktx:1.7.0"
  671. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  672. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
  673. // use leak canary in debug builds
  674. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
  675. // test dependencies
  676. testImplementation "junit:junit:$junit_version"
  677. testImplementation(testFixtures(project(":domain")))
  678. // use powermock instead of mockito. it support mocking static classes.
  679. def mockitoVersion = '2.0.9'
  680. testImplementation "org.powermock:powermock-api-mockito2:${mockitoVersion}"
  681. testImplementation "org.powermock:powermock-module-junit4-rule-agent:${mockitoVersion}"
  682. testImplementation "org.powermock:powermock-module-junit4-rule:${mockitoVersion}"
  683. testImplementation "org.powermock:powermock-module-junit4:${mockitoVersion}"
  684. // add JSON support to tests without mocking
  685. testImplementation 'org.json:json:20190722'
  686. testImplementation 'com.tngtech.archunit:archunit-junit4:0.18.0'
  687. androidTestImplementation(testFixtures(project(":domain")))
  688. androidTestImplementation 'androidx.test:rules:1.4.0'
  689. androidTestImplementation 'tools.fastlane:screengrab:2.0.0', {
  690. exclude group: 'androidx.annotation', module: 'annotation'
  691. }
  692. androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0', {
  693. exclude group: 'androidx.annotation', module: 'annotation'
  694. }
  695. androidTestImplementation 'androidx.test:runner:1.1.0', {
  696. exclude group: 'androidx.annotation', module: 'annotation'
  697. }
  698. androidTestImplementation 'androidx.test.ext:junit:1.1.3'
  699. androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.1.0', {
  700. exclude group: 'androidx.annotation', module: 'annotation'
  701. exclude group: 'androidx.appcompat', module: 'appcompat'
  702. exclude group: 'androidx.legacy', module: 'legacy-support-v4'
  703. exclude group: 'com.google.android.material', module: 'material'
  704. exclude group: 'androidx.recyclerview', module: 'recyclerview'
  705. }
  706. androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0', {
  707. exclude group: 'androidx.annotation', module: 'annotation'
  708. }
  709. androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
  710. // Google Play Services and related libraries
  711. def googleDependencies = [
  712. // Play services
  713. 'com.google.android.gms:play-services-base:16.1.0': [],
  714. // Firebase push
  715. //
  716. // Note: Do not upgrade to a higher version of firebase-messaging,
  717. // as we do not want the Firebase Installations API in our app
  718. 'com.google.firebase:firebase-messaging:20.1.0': [
  719. [group: 'com.google.firebase', module: 'firebase-core'],
  720. [group: 'com.google.firebase', module: 'firebase-analytics'],
  721. [group: 'com.google.firebase', module: 'firebase-measurement-connector'],
  722. ],
  723. ]
  724. googleDependencies.each {
  725. def dependency = it.key
  726. def excludes = it.value
  727. noneImplementation(dependency) { excludes.each { exclude it } }
  728. store_googleImplementation(dependency) { excludes.each { exclude it } }
  729. store_google_workImplementation(dependency) { excludes.each { exclude it } }
  730. store_threemaImplementation(dependency) { excludes.each { exclude it } }
  731. fdroidImplementation(dependency) { excludes.each { exclude it } }
  732. onpremImplementation(dependency) { excludes.each { exclude it } }
  733. sandboxImplementation(dependency) { excludes.each { exclude it } }
  734. sandbox_workImplementation(dependency) { excludes.each { exclude it } }
  735. redImplementation(dependency) { excludes.each { exclude it } }
  736. }
  737. // Google Assistant Voice Action verification library
  738. noneImplementation(name: 'libgsaverification-client', ext: 'aar')
  739. store_googleImplementation(name: 'libgsaverification-client', ext: 'aar')
  740. store_google_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  741. onpremImplementation(name: 'libgsaverification-client', ext: 'aar')
  742. store_threemaImplementation(name: 'libgsaverification-client', ext: 'aar')
  743. fdroidImplementation(name: 'libgsaverification-client', ext: 'aar')
  744. sandboxImplementation(name: 'libgsaverification-client', ext: 'aar')
  745. sandbox_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  746. redImplementation(name: 'libgsaverification-client', ext: 'aar')
  747. // Huawei related libraries (only for hms* build variants)
  748. def huaweiDependencies = [
  749. // HMS push
  750. 'com.huawei.hms:push:6.3.0.304': [
  751. // Exclude agconnect dependency, we'll replace it with the vendored version below
  752. [group: 'com.huawei.agconnect'],
  753. ],
  754. ]
  755. huaweiDependencies.each {
  756. def dependency = it.key
  757. def excludes = it.value
  758. hmsImplementation(dependency) { excludes.each { exclude it } }
  759. hms_workImplementation(dependency) { excludes.each { exclude it } }
  760. }
  761. hmsImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
  762. hms_workImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
  763. }
  764. sonarqube {
  765. properties {
  766. property "sonar.sources", "src/main/, ../scripts/, ../scripts-internal/"
  767. property "sonar.exclusions", "src/main/java/ch/threema/localcrypto/**, src/test/java/ch/threema/localcrypto/**"
  768. property "sonar.tests", "src/test/"
  769. property "sonar.sourceEncoding", "UTF-8"
  770. property "sonar.verbose", "true"
  771. property 'sonar.projectKey', 'android-client'
  772. property 'sonar.projectName', 'Threema for Android'
  773. }
  774. }
  775. // Set up Gradle tasks to fetch screenshots on UI test failures
  776. // See https://medium.com/stepstone-tech/how-to-capture-screenshots-for-failed-ui-tests-9927eea6e1e4
  777. def reportsDirectory = "$buildDir/reports/androidTests/connected"
  778. def screenshotsDirectory = "/sdcard/testfailures/screenshots/"
  779. def clearScreenshotsTask = task('clearScreenshots', type: Exec) {
  780. executable "${android.getAdbExe().toString()}"
  781. args 'shell', 'rm', '-r', screenshotsDirectory
  782. }
  783. def createScreenshotsDirectoryTask = task('createScreenshotsDirectory', type: Exec, group: 'reporting') {
  784. executable "${android.getAdbExe().toString()}"
  785. args 'shell', 'mkdir', '-p', screenshotsDirectory
  786. }
  787. def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
  788. executable "${android.getAdbExe().toString()}"
  789. args 'pull', screenshotsDirectory + '.', reportsDirectory
  790. finalizedBy {
  791. clearScreenshotsTask
  792. }
  793. dependsOn {
  794. createScreenshotsDirectoryTask
  795. }
  796. doFirst {
  797. new File(reportsDirectory).mkdirs()
  798. }
  799. }
  800. tasks.whenTaskAdded { task ->
  801. if (task.name == 'connectedDebugAndroidTest') {
  802. task.finalizedBy {
  803. fetchScreenshotsTask
  804. }
  805. }
  806. }