build.gradle 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. apply plugin: 'com.android.library'
  2. apply plugin: 'maven'
  3. repositories {
  4. mavenCentral()
  5. maven {
  6. url "https://oss.sonatype.org/content/repositories/snapshots"
  7. }
  8. flatDir {
  9. dirs 'aars'
  10. }
  11. }
  12. android {
  13. configurations {
  14. extractForNativeBuild
  15. }
  16. compileSdkVersion rootProject.compileSdkVersion
  17. buildToolsVersion rootProject.buildToolsVersion
  18. defaultConfig {
  19. minSdkVersion rootProject.minSdkVersion
  20. targetSdkVersion rootProject.targetSdkVersion
  21. versionCode 0
  22. versionName "0.1"
  23. testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
  24. ndk {
  25. abiFilters ABI_FILTERS.split(",")
  26. }
  27. }
  28. buildTypes {
  29. debug {
  30. minifyEnabled false
  31. debuggable true
  32. }
  33. release {
  34. minifyEnabled false
  35. }
  36. }
  37. externalNativeBuild {
  38. cmake {
  39. path "CMakeLists.txt"
  40. }
  41. }
  42. useLibrary 'android.test.runner'
  43. useLibrary 'android.test.base'
  44. useLibrary 'android.test.mock'
  45. }
  46. dependencies {
  47. implementation 'com.android.support:appcompat-v7:' + rootProject.androidSupportAppCompatV7Version
  48. extractForNativeBuild "org.pytorch:pytorch_android:$pytorchAndroidVersion"
  49. // For testing: deps on local aar files
  50. //implementation(name: 'pytorch_android-release', ext: 'aar')
  51. //extractForNativeBuild(name: 'pytorch_android-release', ext: 'aar')
  52. //implementation 'com.facebook.fbjni:fbjni-java-only:0.0.3'
  53. }
  54. task extractAARForNativeBuild {
  55. doLast {
  56. configurations.extractForNativeBuild.files.each {
  57. def file = it.absoluteFile
  58. copy {
  59. from zipTree(file)
  60. into "$buildDir/$file.name"
  61. include "headers/**"
  62. include "jni/**"
  63. }
  64. }
  65. }
  66. }
  67. tasks.whenTaskAdded { task ->
  68. if (task.name.contains('externalNativeBuild')) {
  69. task.dependsOn(extractAARForNativeBuild)
  70. }
  71. }
  72. apply from: rootProject.file('gradle_scripts/release.gradle')
  73. task sourcesJar(type: Jar) {
  74. from android.sourceSets.main.java.srcDirs
  75. classifier = 'sources'
  76. }
  77. artifacts.add('archives', sourcesJar)