build.gradle 42 KB

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