build.gradle.in 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // Top-level build file where you can add configuration options common to all sub-projects/modules.
  2. buildscript {
  3. repositories {
  4. google()
  5. jcenter()
  6. }
  7. dependencies {
  8. classpath 'com.android.tools.build:gradle:@ANDROID_GRADLE_PLUGIN_VERSION@'
  9. classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:@KOTLIN_PLUGIN_VERSION@'
  10. // NOTE: Do not place your application dependencies here; they belong
  11. // in the individual module build.gradle files
  12. }
  13. }
  14. allprojects {
  15. repositories {
  16. google()
  17. jcenter()
  18. if (gradle.opencv_source == "maven_local") {
  19. maven {
  20. url gradle.opencv_maven_path
  21. }
  22. }
  23. }
  24. }
  25. task clean(type: Delete) {
  26. delete rootProject.buildDir
  27. }
  28. //allprojects {
  29. // gradle.projectsEvaluated {
  30. // tasks.withType(JavaCompile) {
  31. // options.compilerArgs << "-Xlint:unchecked"
  32. // options.compilerArgs << "-Xlint:deprecation"
  33. // }
  34. // }
  35. //}
  36. def opencv_strict_build_configuration = @ANDROID_STRICT_BUILD_CONFIGURATION@;
  37. gradle.afterProject { project ->
  38. if (project.pluginManager.hasPlugin('com.android.application')
  39. || project.pluginManager.hasPlugin('com.android.library')
  40. || project.pluginManager.hasPlugin('com.android.test')
  41. || project.pluginManager.hasPlugin('com.android.feature') ) {
  42. if (true) {
  43. gradle.println("Override build ABIs for the project ${project.name}")
  44. project.android {
  45. splits {
  46. abi {
  47. enable true
  48. universalApk false
  49. @ANDROID_ABI_FILTER@
  50. }
  51. }
  52. }
  53. }
  54. if (true) {
  55. gradle.println("Override lintOptions for the project ${project.name}")
  56. project.android {
  57. lintOptions {
  58. // checkReleaseBuilds false
  59. abortOnError false
  60. }
  61. }
  62. }
  63. // (you still need to re-build OpenCV with debug information to debug it)
  64. if (true) {
  65. gradle.println("Override doNotStrip-debug for the project ${project.name}")
  66. project.android {
  67. buildTypes {
  68. debug {
  69. packagingOptions {
  70. doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
  71. }
  72. }
  73. }
  74. }
  75. }
  76. if (false || project.hasProperty("doNotStrip")) {
  77. gradle.println("Override doNotStrip-release for the project ${project.name}")
  78. project.android {
  79. buildTypes {
  80. release {
  81. packagingOptions {
  82. doNotStrip '**/*.so' // controlled by OpenCV CMake scripts
  83. }
  84. }
  85. }
  86. }
  87. }
  88. // Android Gradle Plugin (AGP) 3.5+ is required
  89. // https://github.com/android/ndk-samples/wiki/Configure-NDK-Path
  90. def isNdkVersionSupported = project.android.metaClass.getProperties().find { it.name == 'ndkVersion' } != null
  91. if (opencv_strict_build_configuration && isNdkVersionSupported) {
  92. gradle.println("Override ndkVersion for the project ${project.name}")
  93. project.android {
  94. ndkVersion '@ANDROID_NDK_REVISION@'
  95. }
  96. }
  97. }
  98. }