Skip to content

Commit

Permalink
build(deps): react-native 0.72
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehardy committed Jul 17, 2023
1 parent 2b9dc73 commit ede9bb6
Show file tree
Hide file tree
Showing 38 changed files with 1,304 additions and 2,080 deletions.
10 changes: 3 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,6 @@ gradle-app.setting
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
# gradle/wrapper/gradle-wrapper.properties

### ReactNative.Buck Stack ###
buck-out/
.buckconfig.local
.buckd/
.buckversion
.fakebuckversion

### ReactNative.Linux Stack ###

# temporary files which can be created if a process still has a handle open of a deleted file
Expand Down Expand Up @@ -564,3 +557,6 @@ spelling.json
# Gatsby / Website
website/.cache
website/public

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*
1 change: 1 addition & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jest.doMock('react-native', () => {
},
addAuthStateListener: jest.fn(),
addIdTokenListener: jest.fn(),
setTenantId: jest.fn(),
useEmulator: jest.fn(),
},
RNFBCrashlyticsModule: {},
Expand Down
11 changes: 10 additions & 1 deletion metro.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
module.exports = require('./tests/metro.config');
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
/**
* Metro configuration
* https://facebook.github.io/metro/docs/configuration
*
* @type {import('metro-config').MetroConfig}
*/
const config = require('./tests/metro.config');

module.exports = mergeConfig(getDefaultConfig(__dirname), config);
9 changes: 7 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,15 @@
},
"devDependencies": {
"@babel/core": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-private-methods": "^7.18.6",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@babel/plugin-transform-class-properties": "^7.22.5",
"@babel/preset-env": "^7.22.5",
"@octokit/core": "^4.2.4",
"@tsconfig/node12": "^1.0.11",
"@types/react": "^18.2.14",
"@types/react-native": "^0.70.7",
"@types/react-native": "^0.72.2",
"@typescript-eslint/eslint-plugin": "^5.60.1",
"@typescript-eslint/parser": "^5.60.1",
"babel-jest": "^29.5.0",
Expand Down Expand Up @@ -122,6 +125,8 @@
"**/react/**",
"**/react-native",
"**/react-native/**",
"**/metro-react-native-babel-preset",
"**/metro-react-native-babel-preset/**",
"**/metro-runtime",
"**/metro-runtime/**",
"**/stacktrace-js",
Expand Down
204 changes: 61 additions & 143 deletions tests/android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,55 +1,76 @@
apply plugin: 'com.android.application'
apply plugin: "com.facebook.react"
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.google.firebase.firebase-perf'
apply plugin: 'com.google.firebase.appdistribution'

import com.android.build.OutputFile
import org.apache.tools.ant.taskdefs.condition.Os
import groovy.json.JsonSlurper

project.ext.react = [
enableHermes: true, // clean and rebuild if changing
]
react {
/* Folders */
// The root of your project, i.e. where "package.json" lives. Default is '..'
// root = file("../")
// The folder where the react-native NPM package is. Default is ../node_modules/react-native
// reactNativeDir = file("../node_modules/react-native")
// The folder where the react-native Codegen package is. Default is ../node_modules/@react-native/codegen
// codegenDir = file("../node_modules/@react-native/codegen")
// The cli.js file which is the React Native CLI entrypoint. Default is ../node_modules/react-native/cli.js
// cliFile = file("../node_modules/react-native/cli.js")
/* Variants */
// The list of variants to that are debuggable. For those we're going to
// skip the bundling of the JS bundle and the assets. By default is just 'debug'.
// If you add flavors like lite, prod, etc. you'll have to list your debuggableVariants.
// debuggableVariants = ["liteDebug", "prodDebug"]
/* Bundling */
// A list containing the node command and its flags. Default is just 'node'.
// nodeExecutableAndArgs = ["node"]
//
// The command to run when bundling. By default is 'bundle'
// bundleCommand = "ram-bundle"
//
// The path to the CLI configuration file. Default is empty.
// bundleConfig = file(../rn-cli.config.js)
//
// The name of the generated asset file containing your JS bundle
// bundleAssetName = "MyApplication.android.bundle"
//
// The entry file for bundle generation. Default is 'index.android.js' or 'index.js'
// entryFile = file("../js/MyApplication.android.js")
//
// A list of extra flags to pass to the 'bundle' commands.
// See https://github.com/react-native-community/cli/blob/main/docs/commands.md#bundle
// extraPackagerArgs = []
/* Hermes Commands */
// The hermes compiler command to run. By default it is 'hermesc'
// hermesCommand = "$rootDir/my-custom-hermesc/bin/hermesc"
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
}

// up to mono root
apply from: '../../node_modules/react-native/react.gradle'
/**
* Set this to true to Run Proguard on Release builds to minify the Java bytecode.
*/
def enableProguardInReleaseBuilds = true

/**
* The preferred build flavor of JavaScriptCore.
* The preferred build flavor of JavaScriptCore (JSC)
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'

def enableSeparateBuildPerCPUArchitecture = false

/**
* Use international variant JavaScriptCore
* International variant includes ICU i18n library and necessary data allowing to use
* e.g. Date.toLocaleString and String.localeCompare that give correct results
* when using with locales other than en-US.
* Note that this variant is about 6MiB larger per architecture than default.
*/
def useIntlJsc = false

/**
* Architectures to build native code for.
*/
def reactNativeArchitectures() {
def value = project.getProperties().get("reactNativeArchitectures")
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
namespace "com.invertase.testing"
aaptOptions {
// https://firebase.google.com/docs/ml/android/use-custom-models#local_model
noCompress 'tflite'
Expand All @@ -60,80 +81,13 @@ android {
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 200
versionName '1.0'
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
if (isNewArchitectureEnabled()) {
// We configure the CMake build only if you decide to opt-in for the New Architecture.
externalNativeBuild {
cmake {
arguments "-DPROJECT_BUILD_DIR=$buildDir",
"-DREACT_ANDROID_DIR=$rootDir/../node_modules/react-native/ReactAndroid",
"-DREACT_ANDROID_BUILD_DIR=$rootDir/../node_modules/react-native/ReactAndroid/build",
"-DNODE_MODULES_DIR=$rootDir/../node_modules",
"-DANDROID_STL=c++_shared"
}
}
if (!enableSeparateBuildPerCPUArchitecture) {
ndk {
abiFilters (*reactNativeArchitectures())
}
}
}

// detox items
testBuildType System.getProperty('testBuildType', 'debug')
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
missingDimensionStrategy 'detox', 'full'
}

if (isNewArchitectureEnabled()) {
// We configure the NDK build only if you decide to opt-in for the New Architecture.
externalNativeBuild {
cmake {
path "$projectDir/src/main/jni/CMakeLists.txt"
}
}
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
into("$buildDir/react-ndk/exported")
}
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
into("$buildDir/react-ndk/exported")
}
afterEvaluate {
// If you wish to add a custom TurboModule or component locally,
// you should uncomment this line.
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
// Due to a bug inside AGP, we have to explicitly set a dependency
// between configureCMakeDebug* tasks and the preBuild tasks.
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
configureCMakeRelWithDebInfo.dependsOn(preReleaseBuild)
configureCMakeDebug.dependsOn(preDebugBuild)
reactNativeArchitectures().each { architecture ->
tasks.findByName("configureCMakeDebug[${architecture}]")?.configure {
dependsOn("preDebugBuild")
}
tasks.findByName("configureCMakeRelWithDebInfo[${architecture}]")?.configure {
dependsOn("preReleaseBuild")
}
}
}
}

splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include (*reactNativeArchitectures())
}
}

signingConfigs {
release {
storeFile file('keystore.jks')
Expand All @@ -150,7 +104,7 @@ android {
signingConfig signingConfigs.release // sign with shared SHA256; configured in firebase dynamic-links
}
release {
minifyEnabled true
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
signingConfig signingConfigs.release
Expand All @@ -166,28 +120,13 @@ android {
includeAndroidResources = true
}
}

// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ['armeabi-v7a': 1, 'x86': 2, 'arm64-v8a': 3, 'x86_64': 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}

apply from: './jacoco.gradle'

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")

implementation("androidx.annotation:annotation:${rootProject.ext.androidxAnnotationVersion}")
implementation("androidx.appcompat:appcompat:${rootProject.ext.appCompatVersion}")
Expand All @@ -199,31 +138,18 @@ dependencies {
implementation("androidx.vectordrawable:vectordrawable-animated:${rootProject.ext.vectordrawableVersion}")
implementation("androidx.vectordrawable:vectordrawable:${rootProject.ext.vectordrawableVersion}")

if (project.ext.react.enableHermes) {
//noinspection GradleDynamicVersion
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}")
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.squareup.okhttp3', module:'okhttp'
}

debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
} else {
implementation jscFlavor
}

if (isNewArchitectureEnabled()) {
// If new architecture is enabled, we let you build RN from source
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
// This will be applied to all the imported transtitive dependency.
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute(module("com.facebook.react:react-native"))
.using(project(":ReactAndroid"))
.because("On New Architecture we're building React Native from source")
substitute(module("com.facebook.react:hermes-engine"))
.using(project(":ReactAndroid:hermes-engine"))
.because("On New Architecture we're building Hermes from source")
}
}
}


/* ------------------------
* TESTING SDKS/LIBRARIES
* ------------------------ */
Expand All @@ -235,11 +161,3 @@ dependencies {
}

apply from: file('../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle'); applyNativeModulesAppBuildGradle(project)

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"
}
6 changes: 3 additions & 3 deletions tests/android/app/jacoco.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ task jacocoTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest', 'conn
}

reports {
xml.enabled = true
xml.required = true
html.destination htmlOutDir
}

Expand Down Expand Up @@ -97,7 +97,7 @@ task jacocoUnitTestReport(type: JacocoReport, dependsOn: ['testDebugUnitTest'])
}

reports {
xml.enabled = true
xml.required = true
html.destination htmlOutDir
}

Expand All @@ -122,7 +122,7 @@ task jacocoAndroidTestReport(type: JacocoReport) {
}

reports {
xml.enabled = true
xml.required = true
html.destination htmlOutDir
}

Expand Down
4 changes: 1 addition & 3 deletions tests/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:installLocation="auto"
package="com.invertase.testing">
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
Loading

1 comment on commit ede9bb6

@vercel
Copy link

@vercel vercel bot commented on ede9bb6 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.