-
-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new architecture support (#649)
* feat: rn 70 ios builds with new arch * feat: android migration wip * fix: update test-app, react-native and react version, fix codegen config * fix: change spec for backward compat * fix: simplify android code and make it work * fix: ios code * fix: remove unnecessary folly version * fix: srcDirs on paper * refactor: review * refactor: review * refactor: node 18 * docs: new arch in readme * docs: new arch in readme * refactor: use Spec --------- Co-authored-by: Wojciech Lewicki <[email protected]>
- Loading branch information
Showing
21 changed files
with
3,404 additions
and
2,583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,62 @@ | ||
buildscript { | ||
if (project == rootProject) { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath 'com.android.tools.build:gradle:3.5.3' | ||
} | ||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeDocumentPicker_' + name]).toInteger() | ||
} | ||
|
||
def safeExtGet(prop, fallback) { | ||
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback | ||
def isNewArchitectureEnabled() { | ||
// To opt-in for the New Architecture, you can either: | ||
// - Set `newArchEnabled` to true inside the `gradle.properties` file | ||
// - Invoke gradle with `-newArchEnabled=true` | ||
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true` | ||
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true" | ||
} | ||
|
||
apply plugin: 'com.android.library' | ||
if (isNewArchitectureEnabled()) { | ||
apply plugin: "com.facebook.react" | ||
} | ||
|
||
|
||
android { | ||
compileSdkVersion safeExtGet('compileSdkVersion', 29) | ||
buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2') | ||
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') | ||
|
||
// Used to override the NDK path/version on internal CI or by allowing | ||
// users to customize the NDK path/version from their root project (e.g. for M1 support) | ||
if (rootProject.hasProperty("ndkPath")) { | ||
ndkPath rootProject.ext.ndkPath | ||
} | ||
if (rootProject.hasProperty("ndkVersion")) { | ||
ndkVersion rootProject.ext.ndkVersion | ||
} | ||
|
||
defaultConfig { | ||
minSdkVersion safeExtGet('minSdkVersion', 21) | ||
targetSdkVersion safeExtGet('targetSdkVersion', 29) | ||
versionCode 1 | ||
versionName "1.0" | ||
minSdkVersion getExtOrIntegerDefault('minSdkVersion') | ||
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') | ||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString() | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
sourceSets.main { | ||
java { | ||
if (!isNewArchitectureEnabled()) { | ||
srcDirs += 'src/paper/java' | ||
} | ||
} | ||
} | ||
lintOptions { | ||
disable 'GradleCompatible' | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url("$rootDir/../node_modules/react-native/android") | ||
} | ||
google() | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
//noinspection GradleDynamicVersion | ||
implementation "com.facebook.react:react-native:+" // From node_modules | ||
implementation 'com.facebook.react:react-native:+' // from node_modules | ||
} |
28 changes: 0 additions & 28 deletions
28
android/src/main/java/com/reactnativedocumentpicker/DocumentPickerPackage.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.reactnativedocumentpicker; | ||
|
||
import androidx.annotation.Nullable; | ||
|
||
import com.facebook.react.TurboReactPackage; | ||
import com.facebook.react.bridge.NativeModule; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.module.model.ReactModuleInfo; | ||
import com.facebook.react.module.model.ReactModuleInfoProvider; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class RNDocumentPickerPackage extends TurboReactPackage { | ||
|
||
@Nullable | ||
@Override | ||
public NativeModule getModule(String name, ReactApplicationContext reactContext) { | ||
if (name.equals(RNDocumentPickerModule.NAME)) { | ||
return new RNDocumentPickerModule(reactContext); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public ReactModuleInfoProvider getReactModuleInfoProvider() { | ||
return () -> { | ||
boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED; | ||
final Map<String, ReactModuleInfo> moduleInfos = new HashMap<>(); | ||
moduleInfos.put( | ||
RNDocumentPickerModule.NAME, | ||
new ReactModuleInfo( | ||
RNDocumentPickerModule.NAME, | ||
RNDocumentPickerModule.NAME, | ||
// "DocumentPickerModule", | ||
false, // canOverrideExistingModule | ||
false, // needsEagerInit | ||
true, // hasConstants | ||
false, // isCxxModule | ||
isTurboModule // isTurboModule | ||
)); | ||
return moduleInfos; | ||
}; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
android/src/paper/java/com/reactnativedocumentpicker/NativeDocumentPickerSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Then it was commited. It is here to support the old architecture. | ||
* If you use the new architecture, this file won't be included and instead will be generated by the codegen. | ||
* | ||
* @generated by codegen project: GenerateModuleJavaSpec.js | ||
* | ||
* @nolint | ||
*/ | ||
|
||
package com.reactnativedocumentpicker; | ||
|
||
import com.facebook.proguard.annotations.DoNotStrip; | ||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.ReactModuleWithSpec; | ||
import com.facebook.react.bridge.ReadableArray; | ||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
|
||
public abstract class NativeDocumentPickerSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule { | ||
public NativeDocumentPickerSpec(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@ReactMethod | ||
@DoNotStrip | ||
public abstract void pick(ReadableMap options, Promise promise); | ||
|
||
@ReactMethod | ||
@DoNotStrip | ||
public abstract void releaseSecureAccess(ReadableArray uris, Promise promise); | ||
|
||
@ReactMethod | ||
@DoNotStrip | ||
public abstract void pickDirectory(Promise promise); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
buildscript { | ||
def androidTestAppDir = "../../node_modules/react-native-test-app/android" | ||
apply(from: "${androidTestAppDir}/dependencies.gradle") | ||
def androidTestAppDir = "../../node_modules/react-native-test-app/android" | ||
apply(from: "${androidTestAppDir}/dependencies.gradle") | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
dependencies { | ||
classpath "com.android.tools.build:gradle:$androidPluginVersion" | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" | ||
dependencies { | ||
getReactNativeDependencies().each { dependency -> | ||
classpath(dependency) | ||
} | ||
} | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url("${rootDir}/../../node_modules/react-native/android") | ||
} | ||
mavenCentral() | ||
google() | ||
repositories { | ||
maven { | ||
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm | ||
url("${rootDir}/../../node_modules/react-native/android") | ||
} | ||
mavenCentral() | ||
google() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.