build.gradle 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. apply plugin: 'com.android.application'
  2. apply plugin: 'witness'
  3. apply from: 'witness.gradle'
  4. def getStdout = { command, defaultValue ->
  5. def stdout = new ByteArrayOutputStream()
  6. try {
  7. exec {
  8. commandLine = command
  9. standardOutput = stdout
  10. }
  11. return stdout.toString().trim()
  12. } catch (Exception ignored) {
  13. return defaultValue
  14. }
  15. }
  16. android {
  17. compileSdkVersion 30
  18. buildToolsVersion '30.0.3'
  19. packagingOptions {
  20. doNotStrip '**/*.so'
  21. }
  22. defaultConfig {
  23. minSdkVersion 16
  24. targetSdkVersion 30
  25. versionCode 10408
  26. versionName "1.4.8"
  27. applicationId "org.briarproject.briar.android"
  28. vectorDrawables.useSupportLibrary = true
  29. buildConfigField "String", "GitHash",
  30. "\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
  31. def now = (long) (System.currentTimeMillis() / 1000)
  32. buildConfigField "Long", "BuildTimestamp",
  33. "${getStdout(['git', 'log', '-n', '1', '--format=%ct'], now)}000L"
  34. testInstrumentationRunner 'org.briarproject.briar.android.BriarTestRunner'
  35. testInstrumentationRunnerArguments disableAnalytics: 'true'
  36. }
  37. buildTypes {
  38. debug {
  39. applicationIdSuffix ".debug"
  40. shrinkResources false
  41. minifyEnabled true
  42. crunchPngs false
  43. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  44. testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-test.txt'
  45. }
  46. release {
  47. shrinkResources false
  48. minifyEnabled true
  49. crunchPngs false
  50. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  51. }
  52. }
  53. flavorDimensions "version"
  54. productFlavors {
  55. screenshot {
  56. dimension "version"
  57. minSdkVersion 21
  58. applicationIdSuffix ".screenshot" // = org.briarproject.briar.android.screenshot.debug
  59. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-test.txt'
  60. }
  61. official {
  62. dimension "version"
  63. }
  64. }
  65. variantFilter { variant ->
  66. if (variant.flavors*.name.contains("screenshot") && variant.buildType.name == "release") {
  67. setIgnore(true)
  68. }
  69. }
  70. compileOptions {
  71. sourceCompatibility JavaVersion.VERSION_1_8
  72. targetCompatibility JavaVersion.VERSION_1_8
  73. }
  74. testOptions {
  75. execution 'ANDROIDX_TEST_ORCHESTRATOR'
  76. unitTests {
  77. includeAndroidResources = true
  78. }
  79. }
  80. lintOptions {
  81. warning 'MissingTranslation'
  82. warning 'ImpliedQuantity'
  83. warning 'ExtraTranslation'
  84. // FIXME
  85. warning 'InvalidPackage'
  86. }
  87. }
  88. dependencies {
  89. implementation project(path: ':briar-core', configuration: 'default')
  90. implementation project(path: ':bramble-core', configuration: 'default')
  91. implementation project(':bramble-android')
  92. implementation 'org.briarproject:dont-kill-me-lib:0.2.2'
  93. implementation 'androidx.fragment:fragment:1.3.4'
  94. implementation 'androidx.preference:preference:1.1.1'
  95. implementation 'androidx.exifinterface:exifinterface:1.3.2'
  96. implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
  97. implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
  98. implementation 'com.google.android.material:material:1.3.0'
  99. implementation 'androidx.recyclerview:recyclerview-selection:1.1.0'
  100. implementation 'info.guardianproject.panic:panic:1.0'
  101. implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
  102. implementation 'de.hdodenhof:circleimageview:3.1.0'
  103. implementation 'com.google.zxing:core:3.3.3' // newer version need minSdk 24
  104. implementation 'uk.co.samuelwall:material-tap-target-prompt:3.3.0'
  105. implementation 'com.vanniktech:emoji-google:0.7.0' // newer versions need minSdk 21
  106. implementation 'com.github.kobakei:MaterialFabSpeedDial:1.2.1'
  107. implementation 'com.github.chrisbanes:PhotoView:2.3.0'
  108. def glideVersion = '4.11.0'
  109. implementation("com.github.bumptech.glide:glide:$glideVersion") {
  110. exclude group: 'com.android.support'
  111. exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
  112. }
  113. implementation 'org.nanohttpd:nanohttpd:2.3.1'
  114. annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
  115. annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
  116. compileOnly 'javax.annotation:jsr250-api:1.0'
  117. def espressoVersion = '3.3.0'
  118. testImplementation project(path: ':bramble-api', configuration: 'testOutput')
  119. testImplementation project(path: ':bramble-core', configuration: 'testOutput')
  120. testImplementation 'androidx.test:runner:1.4.0'
  121. testImplementation 'androidx.test.ext:junit:1.1.3'
  122. testImplementation 'androidx.fragment:fragment-testing:1.4.0'
  123. testImplementation "androidx.arch.core:core-testing:2.1.0"
  124. testImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
  125. testImplementation 'org.robolectric:robolectric:4.4'
  126. testImplementation 'org.mockito:mockito-core:3.9.0'
  127. testImplementation "junit:junit:$junit_version"
  128. testImplementation "org.jmock:jmock:$jmock_version"
  129. testImplementation "org.jmock:jmock-junit4:$jmock_version"
  130. testImplementation "org.jmock:jmock-imposters:$jmock_version"
  131. testAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
  132. androidTestImplementation project(path: ':bramble-api', configuration: 'testOutput')
  133. androidTestImplementation 'androidx.test.ext:junit:1.1.2'
  134. androidTestImplementation "androidx.test.espresso:espresso-core:$espressoVersion"
  135. androidTestImplementation "androidx.test.espresso:espresso-contrib:$espressoVersion"
  136. androidTestImplementation "androidx.test.espresso:espresso-intents:$espressoVersion"
  137. androidTestImplementation 'androidx.test:runner:1.3.0'
  138. androidTestUtil 'androidx.test:orchestrator:1.3.0'
  139. androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
  140. androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
  141. androidTestImplementation "junit:junit:$junit_version"
  142. androidTestScreenshotImplementation 'tools.fastlane:screengrab:2.0.0'
  143. androidTestScreenshotImplementation 'com.jraska:falcon:2.1.1'
  144. androidTestScreenshotImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
  145. }
  146. task verifyTranslations {
  147. doLast {
  148. def file = project.file("src/main/res/values/arrays.xml")
  149. def arrays = new XmlParser().parse(file)
  150. def lc = arrays.children().find { it.@name == "pref_language_values" }
  151. def translations = []
  152. lc.children().each { value -> translations.add(value.text()) }
  153. def folders = ["default", "en-US"]
  154. def exceptions = ["values-night", "values-v21", "values-ldrtl"]
  155. project.file("src/main/res").eachDir { dir ->
  156. if (dir.name.startsWith("values-") && !exceptions.contains(dir.name)) {
  157. folders.add(dir.name.substring(7).replace("-r", "-"))
  158. }
  159. }
  160. folders.each { n ->
  161. if (!translations.remove(n) && n != 'iw') {
  162. throw new GradleException("Translation " + n + " is missing in $file")
  163. }
  164. }
  165. if (translations.size() != 0)
  166. throw new GradleException("Translations\n" + translations.join("\n")
  167. + "\nhave no matching value folder")
  168. // Some devices use iw instead of he for hebrew
  169. def hebrew_legacy = project.file("src/main/res/values-iw")
  170. def hebrew = project.file("src/main/res/values-he")
  171. // Copy values-he to values-iw
  172. if (hebrew.exists()) {
  173. hebrew_legacy.mkdir()
  174. copy {
  175. from hebrew.getAbsolutePath()
  176. into hebrew_legacy.getAbsolutePath()
  177. }
  178. }
  179. }
  180. }
  181. project.afterEvaluate {
  182. preBuild.dependsOn.add(verifyTranslations)
  183. }