|
1 | 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') : rootProject.ext.has('kotlin_version') ? rootProject.ext.get('kotlin_version') : project.properties['Ama_kotlinVersion'] |
| 2 | + ext.getExtOrDefault = {name -> |
| 3 | + return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Ama_' + name] |
| 4 | + } |
4 | 5 |
|
5 | 6 | repositories { |
6 | 7 | google() |
7 | 8 | mavenCentral() |
8 | 9 | } |
9 | 10 |
|
10 | 11 | dependencies { |
11 | | - classpath 'com.android.tools.build:gradle:3.2.1' |
| 12 | + classpath "com.android.tools.build:gradle:8.7.2" |
12 | 13 | // noinspection DifferentKotlinGradleVersion |
13 | | - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" |
| 14 | + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}" |
14 | 15 | } |
15 | 16 | } |
16 | 17 |
|
17 | | -apply plugin: 'com.android.library' |
18 | | -apply plugin: 'kotlin-android' |
19 | 18 |
|
20 | | -def getExtOrDefault(name) { |
21 | | - return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Ama_' + name] |
22 | | -} |
| 19 | +apply plugin: "com.android.library" |
| 20 | +apply plugin: "kotlin-android" |
| 21 | + |
| 22 | +apply plugin: "com.facebook.react" |
23 | 23 |
|
24 | 24 | def getExtOrIntegerDefault(name) { |
25 | | - return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Ama_' + name]).toInteger() |
| 25 | + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Ama_" + name]).toInteger() |
26 | 26 | } |
27 | 27 |
|
28 | 28 | android { |
29 | | - compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') |
| 29 | + namespace "com.ama" |
| 30 | + |
| 31 | + compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") |
| 32 | + |
30 | 33 | defaultConfig { |
31 | | - minSdkVersion 16 |
32 | | - targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') |
33 | | - versionCode 1 |
34 | | - versionName "1.0" |
35 | | - |
| 34 | + minSdkVersion getExtOrIntegerDefault("minSdkVersion") |
| 35 | + targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") |
| 36 | + } |
| 37 | + |
| 38 | + buildFeatures { |
| 39 | + buildConfig true |
36 | 40 | } |
37 | | - |
| 41 | + |
38 | 42 | buildTypes { |
39 | 43 | release { |
40 | 44 | minifyEnabled false |
41 | 45 | } |
42 | 46 | } |
| 47 | + |
43 | 48 | lintOptions { |
44 | | - disable 'GradleCompatible' |
| 49 | + disable "GradleCompatible" |
45 | 50 | } |
| 51 | + |
46 | 52 | compileOptions { |
47 | 53 | sourceCompatibility JavaVersion.VERSION_1_8 |
48 | 54 | targetCompatibility JavaVersion.VERSION_1_8 |
49 | 55 | } |
| 56 | + |
| 57 | + sourceSets { |
| 58 | + main { |
| 59 | + java.srcDirs += [ |
| 60 | + "generated/java", |
| 61 | + "generated/jni" |
| 62 | + ] |
| 63 | + } |
| 64 | + } |
50 | 65 | } |
51 | 66 |
|
52 | 67 | repositories { |
53 | 68 | mavenCentral() |
54 | 69 | google() |
55 | | - |
56 | | - def found = false |
57 | | - def defaultDir = null |
58 | | - def androidSourcesName = 'React Native sources' |
59 | | - |
60 | | - if (rootProject.ext.has('reactNativeAndroidRoot')) { |
61 | | - defaultDir = rootProject.ext.get('reactNativeAndroidRoot') |
62 | | - } else { |
63 | | - defaultDir = new File( |
64 | | - projectDir, |
65 | | - '/../../../node_modules/react-native/android' |
66 | | - ) |
67 | | - } |
68 | | - |
69 | | - if (defaultDir.exists()) { |
70 | | - maven { |
71 | | - url defaultDir.toString() |
72 | | - name androidSourcesName |
73 | | - } |
74 | | - |
75 | | - logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}") |
76 | | - found = true |
77 | | - } else { |
78 | | - def parentDir = rootProject.projectDir |
79 | | - |
80 | | - 1.upto(5, { |
81 | | - if (found) return true |
82 | | - parentDir = parentDir.parentFile |
83 | | - |
84 | | - def androidSourcesDir = new File( |
85 | | - parentDir, |
86 | | - 'node_modules/react-native' |
87 | | - ) |
88 | | - |
89 | | - def androidPrebuiltBinaryDir = new File( |
90 | | - parentDir, |
91 | | - 'node_modules/react-native/android' |
92 | | - ) |
93 | | - |
94 | | - if (androidPrebuiltBinaryDir.exists()) { |
95 | | - maven { |
96 | | - url androidPrebuiltBinaryDir.toString() |
97 | | - name androidSourcesName |
98 | | - } |
99 | | - |
100 | | - logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}") |
101 | | - found = true |
102 | | - } else if (androidSourcesDir.exists()) { |
103 | | - maven { |
104 | | - url androidSourcesDir.toString() |
105 | | - name androidSourcesName |
106 | | - } |
107 | | - |
108 | | - logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}") |
109 | | - found = true |
110 | | - } |
111 | | - }) |
112 | | - } |
113 | | - |
114 | | - if (!found) { |
115 | | - throw new GradleException( |
116 | | - "${project.name}: unable to locate React Native android sources. " + |
117 | | - "Ensure you have you installed React Native as a dependency in your project and try again." |
118 | | - ) |
119 | | - } |
120 | 70 | } |
121 | 71 |
|
122 | | -def kotlin_version = getExtOrDefault('kotlinVersion') |
| 72 | +def kotlin_version = getExtOrDefault("kotlinVersion") |
123 | 73 |
|
124 | 74 | dependencies { |
125 | | - // noinspection GradleDynamicVersion |
126 | | - api 'com.facebook.react:react-native:+' |
| 75 | + implementation "com.facebook.react:react-android" |
127 | 76 | implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" |
128 | 77 | } |
| 78 | + |
| 79 | +react { |
| 80 | + jsRootDir = file("../src/") |
| 81 | + libraryName = "Ama" |
| 82 | + codegenJavaPackageName = "com.ama" |
| 83 | +} |
0 commit comments