Нема описа

build.gradle 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. buildscript {
  2. ext.kotlin_version = '1.2.71'
  3. repositories {
  4. google()
  5. jcenter()
  6. }
  7. dependencies {
  8. classpath 'com.android.tools.build:gradle:3.2.1'
  9. //noinspection DifferentKotlinGradleVersion
  10. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  11. }
  12. }
  13. apply plugin: 'com.android.library'
  14. apply plugin: 'kotlin-android'
  15. def DEFAULT_TARGET_SDK_VERSION = 27
  16. def DEFAULT_COMPILE_SDK_VERSION = 27
  17. def DEFAULT_BUILD_TOOLS_VERSION = "28.0.3"
  18. def DEFAULT_SUPPORT_LIB_VERSION = "28.0.0"
  19. def getExtOrDefault(name, defaultValue) {
  20. return rootProject.ext.has(name) ? rootProject.ext.get(name) : defaultValue
  21. }
  22. android {
  23. compileSdkVersion getExtOrDefault('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
  24. buildToolsVersion getExtOrDefault('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
  25. defaultConfig {
  26. minSdkVersion 16
  27. targetSdkVersion getExtOrDefault('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
  28. versionCode 1
  29. versionName "1.0"
  30. }
  31. buildTypes {
  32. release {
  33. minifyEnabled false
  34. }
  35. }
  36. lintOptions {
  37. disable 'GradleCompatible'
  38. }
  39. compileOptions {
  40. sourceCompatibility JavaVersion.VERSION_1_8
  41. targetCompatibility JavaVersion.VERSION_1_8
  42. }
  43. }
  44. repositories {
  45. mavenCentral()
  46. jcenter()
  47. google()
  48. def found = false
  49. def defaultDir = null
  50. def androidSourcesName = 'React Native sources'
  51. if (rootProject.ext.has('reactNativeAndroidRoot')) {
  52. defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
  53. } else {
  54. defaultDir = new File(
  55. projectDir,
  56. '/../../../node_modules/react-native/android'
  57. )
  58. }
  59. if (defaultDir.exists()) {
  60. maven {
  61. url defaultDir.toString()
  62. name androidSourcesName
  63. }
  64. logger.quiet(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
  65. found = true
  66. } else {
  67. def parentDir = rootProject.projectDir
  68. 1.upto(5, {
  69. if (found) return true
  70. parentDir = parentDir.parentFile
  71. def androidSourcesDir = new File(
  72. parentDir,
  73. 'node_modules/react-native'
  74. )
  75. def androidPrebuiltBinaryDir = new File(
  76. parentDir,
  77. 'node_modules/react-native/android'
  78. )
  79. if (androidPrebuiltBinaryDir.exists()) {
  80. maven {
  81. url androidPrebuiltBinaryDir.toString()
  82. name androidSourcesName
  83. }
  84. logger.quiet(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
  85. found = true
  86. } else if (androidSourcesDir.exists()) {
  87. maven {
  88. url androidSourcesDir.toString()
  89. name androidSourcesName
  90. }
  91. logger.quiet(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
  92. found = true
  93. }
  94. })
  95. }
  96. if (!found) {
  97. throw new GradleException(
  98. "${project.name}: unable to locate React Native android sources. " +
  99. "Ensure you have you installed React Native as a dependency in your project and try again."
  100. )
  101. }
  102. }
  103. def support_version = getExtOrDefault('supportLibVersion', DEFAULT_SUPPORT_LIB_VERSION)
  104. dependencies {
  105. //noinspection GradleDynamicVersion
  106. api 'com.facebook.react:react-native:+'
  107. implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  108. implementation "com.android.support:appcompat-v7:$support_version"
  109. }