build.gradle 45 KB

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