build.gradle 43 KB

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