build.gradle 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 28
  18. buildToolsVersion '28.0.3'
  19. defaultConfig {
  20. minSdkVersion 15
  21. targetSdkVersion 26
  22. versionCode 10106
  23. versionName "1.1.6"
  24. applicationId "org.briarproject.briar.android"
  25. buildConfigField "String", "GitHash",
  26. "\"${getStdout(['git', 'rev-parse', '--short=7', 'HEAD'], 'No commit hash')}\""
  27. def now = (long) (System.currentTimeMillis() / 1000)
  28. buildConfigField "Long", "BuildTimestamp",
  29. "${getStdout(['git', 'log', '-n', '1', '--format=%ct'], now)}000L"
  30. testInstrumentationRunner 'org.briarproject.briar.android.BriarTestRunner'
  31. }
  32. buildTypes {
  33. debug {
  34. applicationIdSuffix ".debug"
  35. shrinkResources false
  36. minifyEnabled true
  37. crunchPngs false
  38. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  39. testProguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt', 'proguard-test.txt'
  40. }
  41. release {
  42. shrinkResources false
  43. minifyEnabled true
  44. crunchPngs false
  45. proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
  46. }
  47. }
  48. flavorDimensions "version"
  49. productFlavors {
  50. screenshot {
  51. dimension "version"
  52. minSdkVersion 18
  53. applicationIdSuffix ".screenshot" // = org.briarproject.briar.android.screenshot.debug
  54. }
  55. official {
  56. dimension "version"
  57. }
  58. }
  59. variantFilter { variant ->
  60. if (variant.flavors*.name.contains("screenshot") && variant.buildType.name == "release") {
  61. setIgnore(true)
  62. }
  63. }
  64. compileOptions {
  65. sourceCompatibility JavaVersion.VERSION_1_8
  66. targetCompatibility JavaVersion.VERSION_1_8
  67. }
  68. testOptions {
  69. unitTests {
  70. includeAndroidResources = true
  71. }
  72. }
  73. lintOptions {
  74. warning 'MissingTranslation'
  75. warning 'ImpliedQuantity'
  76. warning 'ExtraTranslation'
  77. }
  78. }
  79. dependencies {
  80. implementation project(path: ':briar-core', configuration: 'default')
  81. implementation project(path: ':bramble-core', configuration: 'default')
  82. implementation project(':bramble-android')
  83. def supportVersion = '28.0.0'
  84. implementation "com.android.support:support-v4:$supportVersion"
  85. implementation("com.android.support:appcompat-v7:$supportVersion") {
  86. exclude module: 'support-v4'
  87. }
  88. implementation("com.android.support:preference-v14:$supportVersion") {
  89. exclude module: 'support-v4'
  90. }
  91. implementation("com.android.support:design:$supportVersion") {
  92. exclude module: 'support-v4'
  93. exclude module: 'recyclerview-v7'
  94. }
  95. implementation "com.android.support:cardview-v7:$supportVersion"
  96. implementation "com.android.support:support-annotations:$supportVersion"
  97. implementation "com.android.support:exifinterface:$supportVersion"
  98. implementation 'com.android.support.constraint:constraint-layout:1.1.3'
  99. implementation "android.arch.lifecycle:extensions:1.1.1"
  100. implementation('ch.acra:acra:4.11') {
  101. exclude module: 'support-v4'
  102. exclude module: 'support-annotations'
  103. }
  104. implementation 'info.guardianproject.panic:panic:0.5'
  105. implementation 'info.guardianproject.trustedintents:trustedintents:0.2'
  106. implementation 'de.hdodenhof:circleimageview:2.2.0'
  107. implementation 'com.google.zxing:core:3.3.3'
  108. implementation 'uk.co.samuelwall:material-tap-target-prompt:2.14.0'
  109. implementation 'com.vanniktech:emoji-google:0.5.1'
  110. def glideVersion = '4.8.0'
  111. implementation("com.github.bumptech.glide:glide:$glideVersion") {
  112. exclude group: 'com.android.support'
  113. exclude module: 'disklrucache' // when there's no disk cache, we can't accidentally use it
  114. }
  115. implementation 'com.github.chrisbanes:PhotoView:2.1.4' // later versions already use androidx
  116. annotationProcessor 'com.google.dagger:dagger-compiler:2.19'
  117. annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
  118. compileOnly 'javax.annotation:jsr250-api:1.0'
  119. testImplementation project(path: ':bramble-api', configuration: 'testOutput')
  120. testImplementation project(path: ':bramble-core', configuration: 'testOutput')
  121. testImplementation 'org.robolectric:robolectric:4.0.1'
  122. testImplementation 'org.robolectric:shadows-support-v4:3.3.2'
  123. testImplementation 'org.mockito:mockito-core:2.19.0'
  124. testImplementation 'junit:junit:4.12'
  125. testImplementation "org.jmock:jmock:2.8.2"
  126. testImplementation "org.jmock:jmock-junit4:2.8.2"
  127. testImplementation "org.jmock:jmock-legacy:2.8.2"
  128. def espressoVersion = '3.0.2'
  129. androidTestImplementation "com.android.support.test.espresso:espresso-core:$espressoVersion"
  130. androidTestImplementation "com.android.support.test.espresso:espresso-contrib:$espressoVersion"
  131. androidTestImplementation "com.android.support.test.espresso:espresso-intents:$espressoVersion"
  132. androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:2.19"
  133. androidTestCompileOnly 'javax.annotation:jsr250-api:1.0'
  134. androidTestImplementation 'junit:junit:4.12'
  135. androidTestScreenshotImplementation "tools.fastlane:screengrab:1.2.0"
  136. androidTestScreenshotImplementation "com.android.support.test.uiautomator:uiautomator-v18:2.1.3"
  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. }