build.gradle 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 10305
  15. versionName "1.3.5"
  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:0.3.5.15'
  37. tor 'org.briarproject:obfs4proxy-android:0.0.12-dev-40245c4a@zip'
  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-legacy:$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. copy {
  58. from configurations.tor.collect { zipTree(it) }
  59. into torBinariesDir
  60. include 'geoip.zip'
  61. }
  62. configurations.tor.each { outer ->
  63. zipTree(outer).each { inner ->
  64. if (inner.name.endsWith('_arm_pie.zip')) {
  65. copy {
  66. from zipTree(inner)
  67. into torLibsDir
  68. rename '(.*)', 'armeabi-v7a/lib$1.so'
  69. }
  70. } else if (inner.name.endsWith('_arm64_pie.zip')) {
  71. copy {
  72. from zipTree(inner)
  73. into torLibsDir
  74. rename '(.*)', 'arm64-v8a/lib$1.so'
  75. }
  76. } else if (inner.name.endsWith('_x86_pie.zip')) {
  77. copy {
  78. from zipTree(inner)
  79. into torLibsDir
  80. rename '(.*)', 'x86/lib$1.so'
  81. }
  82. } else if (inner.name.endsWith('_x86_64_pie.zip')) {
  83. copy {
  84. from zipTree(inner)
  85. into torLibsDir
  86. rename '(.*)', 'x86_64/lib$1.so'
  87. }
  88. }
  89. }
  90. }
  91. }
  92. dependsOn cleanTorBinaries
  93. }
  94. tasks.withType(MergeResources) {
  95. inputs.dir torBinariesDir
  96. inputs.dir torLibsDir
  97. dependsOn unpackTorBinaries
  98. }