|
1 | 1 | buildscript { |
2 | | - if (project == rootProject) { |
3 | | - repositories { |
4 | | - google() |
5 | | - mavenCentral() |
6 | | - } |
7 | | - |
8 | | - dependencies { |
9 | | - classpath 'com.android.tools.build:gradle:3.5.3' |
10 | | - } |
| 2 | + repositories { |
| 3 | + google() |
| 4 | + mavenCentral() |
11 | 5 | } |
12 | 6 | } |
13 | 7 |
|
14 | | -apply plugin: 'com.android.library' |
| 8 | +def getExtOrIntegerDefault(name) { |
| 9 | + return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeDocumentPicker_' + name]).toInteger() |
| 10 | +} |
15 | 11 |
|
16 | | -def safeExtGet(prop, fallback) { |
17 | | - rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback |
| 12 | +def isNewArchitectureEnabled() { |
| 13 | + // To opt-in for the New Architecture, you can either: |
| 14 | + // - Set `newArchEnabled` to true inside the `gradle.properties` file |
| 15 | + // - Invoke gradle with `-newArchEnabled=true` |
| 16 | + // - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` |
| 17 | + return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" |
18 | 18 | } |
19 | 19 |
|
| 20 | +apply plugin: 'com.android.library' |
| 21 | +if (isNewArchitectureEnabled()) { |
| 22 | + apply plugin: "com.facebook.react" |
| 23 | +} |
| 24 | + |
| 25 | + |
20 | 26 | android { |
21 | | - compileSdkVersion safeExtGet('compileSdkVersion', 29) |
22 | | - buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2') |
| 27 | + compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') |
| 28 | + |
| 29 | + // Used to override the NDK path/version on internal CI or by allowing |
| 30 | + // users to customize the NDK path/version from their root project (e.g. for M1 support) |
| 31 | + if (rootProject.hasProperty("ndkPath")) { |
| 32 | + ndkPath rootProject.ext.ndkPath |
| 33 | + } |
| 34 | + if (rootProject.hasProperty("ndkVersion")) { |
| 35 | + ndkVersion rootProject.ext.ndkVersion |
| 36 | + } |
| 37 | + |
23 | 38 | defaultConfig { |
24 | | - minSdkVersion safeExtGet('minSdkVersion', 21) |
25 | | - targetSdkVersion safeExtGet('targetSdkVersion', 29) |
26 | | - versionCode 1 |
27 | | - versionName "1.0" |
| 39 | + minSdkVersion getExtOrIntegerDefault('minSdkVersion') |
| 40 | + targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') |
| 41 | + buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() |
28 | 42 | } |
29 | 43 |
|
30 | | - buildTypes { |
31 | | - release { |
32 | | - minifyEnabled false |
| 44 | + sourceSets.main { |
| 45 | + java { |
| 46 | + if (!isNewArchitectureEnabled()) { |
| 47 | + srcDirs += 'src/paper/java' |
| 48 | + } |
33 | 49 | } |
34 | 50 | } |
35 | | - lintOptions { |
36 | | - disable 'GradleCompatible' |
37 | | - } |
38 | | - compileOptions { |
39 | | - sourceCompatibility JavaVersion.VERSION_1_8 |
40 | | - targetCompatibility JavaVersion.VERSION_1_8 |
41 | | - } |
42 | 51 | } |
43 | 52 |
|
44 | 53 | repositories { |
45 | | - mavenLocal() |
46 | | - maven { |
47 | | - // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm |
48 | | - url("$rootDir/../node_modules/react-native/android") |
49 | | - } |
50 | 54 | google() |
| 55 | + mavenLocal() |
| 56 | + mavenCentral() |
51 | 57 | } |
52 | 58 |
|
53 | 59 | dependencies { |
54 | 60 | //noinspection GradleDynamicVersion |
55 | | - implementation "com.facebook.react:react-native:+" // From node_modules |
| 61 | + implementation 'com.facebook.react:react-native:+' // from node_modules |
56 | 62 | } |
0 commit comments