Нема описа

build.gradle 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. buildscript {
  2. //Buildscript is evaluated before everything else so we can't use getExtOrDefault
  3. def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['ReactNativeWebView_kotlinVersion']
  4. repositories {
  5. google()
  6. jcenter()
  7. }
  8. dependencies {
  9. classpath 'com.android.tools.build:gradle:3.2.1'
  10. //noinspection DifferentKotlinGradleVersion
  11. classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
  12. }
  13. }
  14. def getExtOrDefault(name) {
  15. return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeWebView_' + name]
  16. }
  17. def getExtOrIntegerDefault(name) {
  18. return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeWebView_' + name]).toInteger()
  19. }
  20. apply plugin: 'com.android.library'
  21. apply plugin: 'kotlin-android'
  22. android {
  23. compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
  24. buildToolsVersion getExtOrDefault('buildToolsVersion')
  25. defaultConfig {
  26. minSdkVersion 16
  27. targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
  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')
  104. def kotlin_version = getExtOrDefault('kotlinVersion')
  105. dependencies {
  106. //noinspection GradleDynamicVersion
  107. api 'com.facebook.react:react-native:+'
  108. implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
  109. implementation "com.android.support:appcompat-v7:$support_version"
  110. }