build.gradle 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  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.1"
  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 909
  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. if (keystores['debug'] != null) {
  457. signingConfig signingConfigs.debug
  458. }
  459. }
  460. release {
  461. debuggable false
  462. jniDebuggable false
  463. minifyEnabled true
  464. shrinkResources false // Caused inconsistencies between local and CI builds
  465. zipAlignEnabled true
  466. multiDexEnabled true
  467. multiDexKeepProguard file('multidex-keep.pro')
  468. proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-project.txt'
  469. if (keystores['release'] != null) {
  470. productFlavors.store_google.signingConfig signingConfigs.release
  471. productFlavors.store_google_work.signingConfig signingConfigs.release
  472. productFlavors.store_threema.signingConfig signingConfigs.release
  473. productFlavors.sandbox.signingConfig signingConfigs.release
  474. productFlavors.sandbox_work.signingConfig signingConfigs.release
  475. productFlavors.none.signingConfig signingConfigs.release
  476. }
  477. if (keystores['hms_release'] != null) {
  478. productFlavors.hms.signingConfig signingConfigs.hms_release
  479. productFlavors.hms_work.signingConfig signingConfigs.hms_release
  480. }
  481. if (keystores['onprem_release'] != null) {
  482. productFlavors.onprem.signingConfig signingConfigs.onprem_release
  483. }
  484. if (keystores['red_release'] != null) {
  485. productFlavors.red.signingConfig signingConfigs.red_release
  486. }
  487. // Note: Libre release is signed with HSM, no config here
  488. }
  489. }
  490. // Only build relevant buildType / flavor combinations
  491. variantFilter { variant ->
  492. def names = variant.flavors*.name
  493. if (
  494. variant.buildType.name == "release" && (
  495. names.contains("sandbox") || names.contains("sandbox_work")
  496. )
  497. ) {
  498. setIgnore(true)
  499. }
  500. }
  501. externalNativeBuild {
  502. ndkBuild {
  503. path 'jni/Android.mk'
  504. }
  505. }
  506. packagingOptions {
  507. jniLibs {
  508. // fix https://stackoverflow.com/questions/42739916/aarch64-linux-android-strip-file-missing
  509. keepDebugSymbols += ['*/mips/*.so', '*/mips64/*.so', '*/armeabi/*.so']
  510. }
  511. resources {
  512. 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']
  513. }
  514. }
  515. testOptions {
  516. // Disable animations in instrumentation tests
  517. animationsDisabled true
  518. unitTests {
  519. all {
  520. // All the usual Gradle options.
  521. testLogging {
  522. events "passed", "skipped", "failed", "standardOut", "standardError"
  523. outputs.upToDateWhen { false }
  524. exceptionFormat = 'full'
  525. }
  526. }
  527. // By default, local unit tests throw an exception any time the code you are testing tries to access
  528. // Android platform APIs (unless you mock Android dependencies yourself or with a testing
  529. // framework like Mockito). However, you can enable the following property so that the test
  530. // returns either null or zero when accessing platform APIs, rather than throwing an exception.
  531. returnDefaultValues true
  532. }
  533. }
  534. compileOptions {
  535. sourceCompatibility JavaVersion.VERSION_11
  536. targetCompatibility JavaVersion.VERSION_11
  537. }
  538. java {
  539. toolchain {
  540. languageVersion.set(JavaLanguageVersion.of(11))
  541. }
  542. }
  543. kotlin {
  544. jvmToolchain(11)
  545. }
  546. androidResources {
  547. noCompress 'png'
  548. }
  549. // Fix non-producible `baseline.profm` in release builds due to unstable ordering.
  550. // See https://issuetracker.google.com/issues/231837768
  551. project.afterEvaluate {
  552. applicationVariants.all { variant ->
  553. if (variant.name.endsWith("Release")) {
  554. tasks["compile${variant.name.capitalize()}ArtProfile"].doLast {
  555. outputs.files.each { file ->
  556. if (file.toString().endsWith(".profm")) {
  557. println("Sorting ${file} ...")
  558. def version = ArtProfileSerializer.valueOf("METADATA_0_0_2")
  559. def profile = ArtProfileKt.ArtProfile(file)
  560. def keys = new ArrayList(profile.profileData.keySet())
  561. def sortedData = new LinkedHashMap()
  562. Collections.sort keys, new DexFile.Companion()
  563. keys.each { key -> sortedData[key] = profile.profileData[key] }
  564. new FileOutputStream(file).with {
  565. write(version.magicBytes$profgen)
  566. write(version.versionBytes$profgen)
  567. version.write$profgen(it, sortedData, "")
  568. }
  569. }
  570. }
  571. }
  572. }
  573. }
  574. }
  575. lint {
  576. // if true, stop the gradle build if errors are found
  577. abortOnError true
  578. // if true, check all issues, including those that are off by default
  579. checkAllWarnings true
  580. // check dependencies
  581. checkDependencies true
  582. // set to true to have all release builds run lint on issues with severity=fatal
  583. // and abort the build (controlled by abortOnError above) if fatal issues are found
  584. checkReleaseBuilds true
  585. // turn off checking the given issue id's
  586. disable 'TypographyFractions', 'TypographyQuotes', 'RtlHardcoded', 'RtlCompat', 'RtlEnabled'
  587. // Set the severity of the given issues to error
  588. error 'Wakelock', 'TextViewEdits', 'ResourceAsColor'
  589. // Set the severity of the given issues to fatal (which means they will be
  590. // checked during release builds (even if the lint target is not included)
  591. fatal 'NewApi', 'InlinedApi'
  592. // Set the severity of the given issues to ignore (same as disabling the check)
  593. ignore 'TypographyQuotes'
  594. ignoreWarnings false
  595. // if true, don't include source code lines in the error output
  596. noLines false
  597. // if true, show all locations for an error, do not truncate lists, etc.
  598. showAll true
  599. // Set the severity of the given issues to warning
  600. warning 'MissingTranslation'
  601. // if true, treat all warnings as errors
  602. warningsAsErrors false
  603. // file to write report to (if not specified, defaults to lint-results.xml)
  604. xmlOutput file('lint-report.xml')
  605. // if true, generate an XML report for use by for example Jenkins
  606. xmlReport true
  607. }
  608. }
  609. dependencies {
  610. configurations.all {
  611. // Prefer modules that are part of this build (multi-project or composite build)
  612. // over external modules
  613. resolutionStrategy.preferProjectModules()
  614. // Alternatively, we can fail eagerly on version conflict to see the conflicts
  615. //resolutionStrategy.failOnVersionConflict()
  616. }
  617. implementation project(':domain')
  618. implementation 'net.zetetic:sqlcipher-android:4.5.4@aar'
  619. implementation 'com.davemorrissey.labs:subsampling-scale-image-view-androidx:3.10.0'
  620. implementation 'net.sf.opencsv:opencsv:2.3'
  621. implementation 'net.lingala.zip4j:zip4j:2.11.5'
  622. implementation 'com.getkeepsafe.taptargetview:taptargetview:1.13.3'
  623. // commons-io >2.6 requires android 8
  624. implementation 'commons-io:commons-io:2.6'
  625. implementation 'org.apache.commons:commons-text:1.10.0'
  626. implementation "org.slf4j:slf4j-api:$slf4j_version"
  627. implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
  628. implementation 'com.github.CanHub:Android-Image-Cropper:4.3.0'
  629. implementation 'com.datatheorem.android.trustkit:trustkit:1.1.5'
  630. implementation 'me.zhanghai.android.fastscroll:library:1.2.0'
  631. implementation 'com.googlecode.ez-vcard:ez-vcard:0.11.3'
  632. // AndroidX / Jetpack support libraries
  633. implementation "androidx.preference:preference-ktx:1.2.0"
  634. implementation 'androidx.recyclerview:recyclerview:1.3.0'
  635. implementation 'androidx.palette:palette-ktx:1.0.0'
  636. implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
  637. implementation 'androidx.appcompat:appcompat:1.6.1'
  638. implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
  639. implementation 'androidx.biometric:biometric:1.1.0'
  640. implementation 'androidx.work:work-runtime-ktx:2.8.1'
  641. implementation 'androidx.fragment:fragment-ktx:1.5.7'
  642. implementation 'androidx.activity:activity-ktx:1.7.2'
  643. implementation 'androidx.sqlite:sqlite:2.2.2'
  644. implementation "androidx.concurrent:concurrent-futures:1.1.0"
  645. implementation "androidx.camera:camera-camera2:1.3.0-beta01"
  646. implementation "androidx.camera:camera-lifecycle:1.3.0-beta01"
  647. implementation "androidx.camera:camera-view:1.3.0-beta01"
  648. implementation 'androidx.camera:camera-video:1.3.0-beta01'
  649. implementation "androidx.media:media:1.6.0"
  650. implementation 'androidx.media3:media3-exoplayer:1.1.1'
  651. implementation 'androidx.media3:media3-ui:1.1.1'
  652. implementation "androidx.media3:media3-session:1.1.1"
  653. implementation 'androidx.multidex:multidex:2.0.1'
  654. implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
  655. implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.6.1"
  656. implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
  657. implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1"
  658. implementation "androidx.lifecycle:lifecycle-service:2.6.1"
  659. implementation "androidx.lifecycle:lifecycle-process:2.6.1"
  660. implementation "androidx.lifecycle:lifecycle-common-java8:2.6.1"
  661. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
  662. implementation "androidx.paging:paging-runtime-ktx:3.1.1"
  663. implementation "androidx.sharetarget:sharetarget:1.2.0"
  664. implementation 'androidx.room:room-runtime:2.5.1'
  665. kapt 'androidx.room:room-compiler:2.5.1'
  666. implementation 'com.google.android.material:material:1.9.0'
  667. implementation 'com.google.zxing:core:3.3.3' // zxing 3.4 crashes on API < 24
  668. implementation 'com.googlecode.libphonenumber:libphonenumber:8.13.7' // make sure to update this in domain's build.gradle as well
  669. // webclient dependencies
  670. implementation 'org.msgpack:msgpack-core:0.8.24!!'
  671. implementation 'com.fasterxml.jackson.core:jackson-core:2.12.5!!'
  672. implementation 'com.neovisionaries:nv-websocket-client:2.9'
  673. // Backport of Streams and CompletableFuture. Remove once API level 24 is supported.
  674. implementation 'net.sourceforge.streamsupport:streamsupport-cfuture:1.7.4'
  675. implementation('org.saltyrtc:saltyrtc-client:0.14.2') {
  676. exclude group: 'org.json'
  677. }
  678. implementation 'org.saltyrtc:chunked-dc:1.0.1'
  679. implementation 'ch.threema:webrtc-android:110.0.0'
  680. implementation('org.saltyrtc:saltyrtc-task-webrtc:0.18.1') {
  681. exclude module: 'saltyrtc-client'
  682. }
  683. // Glide components
  684. // Glide 4.15+ does not work on API 21
  685. implementation 'com.github.bumptech.glide:glide:4.14.2'
  686. kapt 'com.github.bumptech.glide:compiler:4.14.2'
  687. annotationProcessor 'com.github.bumptech.glide:compiler:4.14.2'
  688. // kotlin
  689. implementation 'androidx.core:core-ktx:1.10.1'
  690. implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
  691. implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
  692. // use leak canary in debug builds
  693. // debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'
  694. // test dependencies
  695. testImplementation "junit:junit:$junit_version"
  696. testImplementation(testFixtures(project(":domain")))
  697. // use powermock instead of mockito. it support mocking static classes.
  698. def mockitoVersion = '2.0.9'
  699. testImplementation "org.powermock:powermock-api-mockito2:${mockitoVersion}"
  700. testImplementation "org.powermock:powermock-module-junit4-rule-agent:${mockitoVersion}"
  701. testImplementation "org.powermock:powermock-module-junit4-rule:${mockitoVersion}"
  702. testImplementation "org.powermock:powermock-module-junit4:${mockitoVersion}"
  703. // add JSON support to tests without mocking
  704. testImplementation 'org.json:json:20220924'
  705. testImplementation 'com.tngtech.archunit:archunit-junit4:0.18.0'
  706. androidTestImplementation(testFixtures(project(":domain")))
  707. androidTestImplementation 'androidx.test:rules:1.5.0'
  708. androidTestImplementation 'tools.fastlane:screengrab:2.1.1', {
  709. exclude group: 'androidx.annotation', module: 'annotation'
  710. }
  711. androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0', {
  712. exclude group: 'androidx.annotation', module: 'annotation'
  713. }
  714. androidTestImplementation 'androidx.test:runner:1.4.0', {
  715. exclude group: 'androidx.annotation', module: 'annotation'
  716. }
  717. androidTestImplementation 'androidx.test.ext:junit:1.1.5'
  718. androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0', {
  719. exclude group: 'androidx.annotation', module: 'annotation'
  720. exclude group: 'androidx.appcompat', module: 'appcompat'
  721. exclude group: 'androidx.legacy', module: 'legacy-support-v4'
  722. exclude group: 'com.google.android.material', module: 'material'
  723. exclude group: 'androidx.recyclerview', module: 'recyclerview'
  724. exclude(group: 'org.checkerframework', module: 'checker')
  725. exclude module: "protobuf-lite"
  726. }
  727. androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0', {
  728. exclude group: 'androidx.annotation', module: 'annotation'
  729. }
  730. androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
  731. // Google Play Services and related libraries
  732. def googleDependencies = [
  733. // Play services
  734. 'com.google.android.gms:play-services-base:18.1.0': [],
  735. // Firebase push
  736. 'com.google.firebase:firebase-messaging:23.1.1': [
  737. [group: 'com.google.firebase', module: 'firebase-core'],
  738. [group: 'com.google.firebase', module: 'firebase-analytics'],
  739. [group: 'com.google.firebase', module: 'firebase-measurement-connector'],
  740. ],
  741. ]
  742. googleDependencies.each {
  743. def dependency = it.key
  744. def excludes = it.value
  745. noneImplementation(dependency) { excludes.each { exclude it } }
  746. store_googleImplementation(dependency) { excludes.each { exclude it } }
  747. store_google_workImplementation(dependency) { excludes.each { exclude it } }
  748. store_threemaImplementation(dependency) { excludes.each { exclude it } }
  749. onpremImplementation(dependency) { excludes.each { exclude it } }
  750. sandboxImplementation(dependency) { excludes.each { exclude it } }
  751. sandbox_workImplementation(dependency) { excludes.each { exclude it } }
  752. redImplementation(dependency) { excludes.each { exclude it } }
  753. }
  754. // Google Assistant Voice Action verification library
  755. noneImplementation(name: 'libgsaverification-client', ext: 'aar')
  756. store_googleImplementation(name: 'libgsaverification-client', ext: 'aar')
  757. store_google_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  758. onpremImplementation(name: 'libgsaverification-client', ext: 'aar')
  759. store_threemaImplementation(name: 'libgsaverification-client', ext: 'aar')
  760. sandboxImplementation(name: 'libgsaverification-client', ext: 'aar')
  761. sandbox_workImplementation(name: 'libgsaverification-client', ext: 'aar')
  762. redImplementation(name: 'libgsaverification-client', ext: 'aar')
  763. // Maplibre (may have transitive dependencies on Google location services)
  764. def maplibreDependency = 'org.maplibre.gl:android-sdk:9.6.0'
  765. noneImplementation maplibreDependency
  766. store_googleImplementation maplibreDependency
  767. store_google_workImplementation maplibreDependency
  768. store_threemaImplementation maplibreDependency
  769. libreImplementation maplibreDependency, { exclude group: 'com.google.android.gms' }
  770. onpremImplementation maplibreDependency
  771. sandboxImplementation maplibreDependency
  772. sandbox_workImplementation maplibreDependency
  773. redImplementation maplibreDependency
  774. hmsImplementation maplibreDependency
  775. hms_workImplementation maplibreDependency
  776. // Huawei related libraries (only for hms* build variants)
  777. def huaweiDependencies = [
  778. // HMS push
  779. 'com.huawei.hms:push:6.3.0.304': [
  780. // Exclude agconnect dependency, we'll replace it with the vendored version below
  781. [group: 'com.huawei.agconnect'],
  782. ],
  783. ]
  784. huaweiDependencies.each {
  785. def dependency = it.key
  786. def excludes = it.value
  787. hmsImplementation(dependency) { excludes.each { exclude it } }
  788. hms_workImplementation(dependency) { excludes.each { exclude it } }
  789. }
  790. hmsImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
  791. hms_workImplementation(name: 'agconnect-core-1.5.0.300', ext: 'aar')
  792. }
  793. sonarqube {
  794. properties {
  795. property "sonar.sources", "src/main/, ../scripts/, ../scripts-internal/"
  796. property "sonar.exclusions", "src/main/java/ch/threema/localcrypto/**, src/test/java/ch/threema/localcrypto/**"
  797. property "sonar.tests", "src/test/"
  798. property "sonar.sourceEncoding", "UTF-8"
  799. property "sonar.verbose", "true"
  800. property 'sonar.projectKey', 'android-client'
  801. property 'sonar.projectName', 'Threema for Android'
  802. }
  803. }
  804. // Set up Gradle tasks to fetch screenshots on UI test failures
  805. // See https://medium.com/stepstone-tech/how-to-capture-screenshots-for-failed-ui-tests-9927eea6e1e4
  806. def reportsDirectory = "$buildDir/reports/androidTests/connected"
  807. def screenshotsDirectory = "/sdcard/testfailures/screenshots/"
  808. def clearScreenshotsTask = task('clearScreenshots', type: Exec) {
  809. executable "${android.getAdbExe().toString()}"
  810. args 'shell', 'rm', '-r', screenshotsDirectory
  811. }
  812. def createScreenshotsDirectoryTask = task('createScreenshotsDirectory', type: Exec, group: 'reporting') {
  813. executable "${android.getAdbExe().toString()}"
  814. args 'shell', 'mkdir', '-p', screenshotsDirectory
  815. }
  816. def fetchScreenshotsTask = task('fetchScreenshots', type: Exec, group: 'reporting') {
  817. executable "${android.getAdbExe().toString()}"
  818. args 'pull', screenshotsDirectory + '.', reportsDirectory
  819. finalizedBy {
  820. clearScreenshotsTask
  821. }
  822. dependsOn {
  823. createScreenshotsDirectoryTask
  824. }
  825. doFirst {
  826. new File(reportsDirectory).mkdirs()
  827. }
  828. }
  829. tasks.whenTaskAdded { task ->
  830. if (task.name == 'connectedDebugAndroidTest') {
  831. task.finalizedBy {
  832. fetchScreenshotsTask
  833. }
  834. }
  835. }