build.gradle 6.6 KB

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