build.gradle 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import com.android.build.gradle.tasks.MergeResources
  2. apply plugin: 'com.android.library'
  3. apply plugin: 'witness'
  4. apply from: 'witness.gradle'
  5. android {
  6. compileSdkVersion 30
  7. buildToolsVersion '30.0.3'
  8. packagingOptions {
  9. doNotStrip '**/*.so'
  10. }
  11. defaultConfig {
  12. minSdkVersion 16
  13. targetSdkVersion 30
  14. versionCode 10410
  15. versionName "1.4.10"
  16. consumerProguardFiles 'proguard-rules.txt'
  17. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  18. }
  19. compileOptions {
  20. sourceCompatibility JavaVersion.VERSION_1_8
  21. targetCompatibility JavaVersion.VERSION_1_8
  22. }
  23. lintOptions {
  24. // FIXME
  25. warning "LintError"
  26. warning "InvalidPackage"
  27. warning "MissingPermission"
  28. warning "InlinedApi", "ObsoleteSdkInt", "Override", "NewApi", "UnusedAttribute"
  29. }
  30. }
  31. configurations {
  32. tor
  33. }
  34. dependencies {
  35. implementation project(path: ':bramble-core', configuration: 'default')
  36. tor "org.briarproject:tor-android:$tor_version"
  37. tor "org.briarproject:obfs4proxy-android:$obfs4proxy_version"
  38. annotationProcessor "com.google.dagger:dagger-compiler:$dagger_version"
  39. compileOnly 'javax.annotation:jsr250-api:1.0'
  40. testImplementation project(path: ':bramble-api', configuration: 'testOutput')
  41. testImplementation "junit:junit:$junit_version"
  42. testImplementation "org.jmock:jmock:$jmock_version"
  43. testImplementation "org.jmock:jmock-junit4:$jmock_version"
  44. testImplementation "org.jmock:jmock-imposters:$jmock_version"
  45. }
  46. def torBinariesDir = 'src/main/res/raw'
  47. def torLibsDir = 'src/main/jniLibs'
  48. task cleanTorBinaries {
  49. doLast {
  50. delete fileTree(torBinariesDir) { include '*.zip' }
  51. delete fileTree(torLibsDir) { include '**/*.so' }
  52. }
  53. }
  54. clean.dependsOn cleanTorBinaries
  55. task unpackTorBinaries {
  56. doLast {
  57. configurations.tor.each { outer ->
  58. zipTree(outer).each { inner ->
  59. if (inner.name.endsWith('_arm_pie.zip')) {
  60. copy {
  61. from zipTree(inner)
  62. into torLibsDir
  63. rename '(.*)', 'armeabi-v7a/lib$1.so'
  64. }
  65. } else if (inner.name.endsWith('_arm64_pie.zip')) {
  66. copy {
  67. from zipTree(inner)
  68. into torLibsDir
  69. rename '(.*)', 'arm64-v8a/lib$1.so'
  70. }
  71. } else if (inner.name.endsWith('_x86_pie.zip')) {
  72. copy {
  73. from zipTree(inner)
  74. into torLibsDir
  75. rename '(.*)', 'x86/lib$1.so'
  76. }
  77. } else if (inner.name.endsWith('_x86_64_pie.zip')) {
  78. copy {
  79. from zipTree(inner)
  80. into torLibsDir
  81. rename '(.*)', 'x86_64/lib$1.so'
  82. }
  83. }
  84. }
  85. }
  86. }
  87. dependsOn cleanTorBinaries
  88. }
  89. tasks.withType(MergeResources) {
  90. inputs.dir torBinariesDir
  91. inputs.dir torLibsDir
  92. dependsOn unpackTorBinaries
  93. }