build.gradle 6.7 KB

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