react-native-macos/ReactAndroid/build.gradle

473 строки
18 KiB
Groovy
Исходник Обычный вид История

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
2015-09-16 20:38:42 +03:00
plugins {
id("com.android.library")
id("maven")
id("de.undercouch.download")
codegen: set up Gradle plugin for more maintable codegen build steps Summary: Instead of sourcing-in a .gradle file to setup codegen tasks in Gradle, let's define a proper `com.facebook.react.codegen` Gradle plugin, so that any Gradle project (lib/app) can include it via: ``` plugins { id 'com.facebook.react.codegen' } ``` The idea (not yet implemented in this commit) is to then allow those projects to add this section in the projects: ``` codegen { enableCodegen = ... jsRootDir = ... } ``` This is more scalable and less hacky. Important notes: * The Gradle plugin should be prepared during the build, we're not going to publish it to Maven or other repo at this point. * This setup is inspired by composite build setup explained here: https://ncorti.com/blog/gradle-plugins-and-composite-builds * All android specific setup is added under `packages/react-native-codegen/android/` dir, but long term, we may want to move it up to `packages/react-native-codegen/` along side setup for other platforms. * As part of this setup, the plugin will have an option (to be validated) to produce Java specs using https://github.com/square/javapoet * This is the same library already used for React Native Android annotation processors * This generator will not deal with parsing Flow types into schema, it will just takes in the schema and produce Java code * We're evaluating whether JavaPoet is a better choice for Java code generation long term, vs building it in JS via string concatenation: https://github.com/facebook/react-native/blob/master/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js * This commit produces a sample Java code, not the actual codegen output Changelog: [Internal] To try this out, run this Gradle task: ``` USE_CODEGEN=1 ./gradlew :ReactAndroid:generateJava ``` Reviewed By: JoshuaGross, mdvacca Differential Revision: D22917315 fbshipit-source-id: 0b79dba939b73ff1305b4b4fd86ab897c7a48d53
2020-08-04 10:53:16 +03:00
id("com.facebook.react.codegen")
}
2015-09-16 20:38:42 +03:00
import java.nio.file.Paths
2015-09-16 20:38:42 +03:00
import de.undercouch.gradle.tasks.download.Download
import org.apache.tools.ant.taskdefs.condition.Os
import org.apache.tools.ant.filters.ReplaceTokens
// We download various C++ open-source dependencies into downloads.
// We then copy both the downloaded code and our custom makefiles and headers into third-party-ndk.
// After that we build native code from src/main/jni with module path pointing at third-party-ndk.
2015-09-16 20:38:42 +03:00
def customDownloadsDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR")
def downloadsDir = customDownloadsDir ? new File(customDownloadsDir) : new File("$buildDir/downloads")
2015-09-16 20:38:42 +03:00
def thirdPartyNdkDir = new File("$buildDir/third-party-ndk")
// You need to have following folders in this directory:
// - boost_1_63_0
// - double-conversion-1.1.6
// - folly-deprecate-dynamic-initializer
// - glog-0.3.5
def dependenciesPath = System.getenv("REACT_NATIVE_DEPENDENCIES")
// The Boost library is a very large download (>100MB).
// If Boost is already present on your system, define the REACT_NATIVE_BOOST_PATH env variable
// and the build will use that.
def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
// Setup build type for NDK, supported values: {debug, release}
def nativeBuildType = System.getenv("NATIVE_BUILD_TYPE") ?: "release"
2015-09-16 20:38:42 +03:00
task createNativeDepsDirectories {
downloadsDir.mkdirs()
thirdPartyNdkDir.mkdirs()
}
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/react-native-community/boost-for-react-native/releases/download/v${BOOST_VERSION.replace("_", ".")}-0/boost_${BOOST_VERSION}.tar.gz")
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
2015-09-16 20:38:42 +03:00
}
task prepareBoost(dependsOn: boostPath ? [] : [downloadBoost], type: Copy) {
from(boostPath ?: tarTree(resources.gzip(downloadBoost.dest)))
from("src/main/jni/third-party/boost/Android.mk")
include("Android.mk", "boost_${BOOST_VERSION}/boost/**/*.hpp", "boost/boost/**/*.hpp")
includeEmptyDirs = false
into("$thirdPartyNdkDir/boost")
doLast {
file("$thirdPartyNdkDir/boost/boost").renameTo("$thirdPartyNdkDir/boost/boost_${BOOST_VERSION}")
}
2015-09-16 20:38:42 +03:00
}
task downloadDoubleConversion(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "double-conversion-${DOUBLE_CONVERSION_VERSION}.tar.gz"))
2015-09-16 20:38:42 +03:00
}
task prepareDoubleConversion(dependsOn: dependenciesPath ? [] : [downloadDoubleConversion], type: Copy) {
from(dependenciesPath ?: tarTree(downloadDoubleConversion.dest))
from("src/main/jni/third-party/double-conversion/Android.mk")
include("double-conversion-${DOUBLE_CONVERSION_VERSION}/src/**/*", "Android.mk")
filesMatching("*/src/**/*", { fname -> fname.path = "double-conversion/${fname.name}" })
2015-09-16 20:38:42 +03:00
includeEmptyDirs = false
into("$thirdPartyNdkDir/double-conversion")
2015-09-16 20:38:42 +03:00
}
task downloadFolly(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/facebook/folly/archive/v${FOLLY_VERSION}.tar.gz")
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "folly-${FOLLY_VERSION}.tar.gz"))
2015-09-16 20:38:42 +03:00
}
task prepareFolly(dependsOn: dependenciesPath ? [] : [downloadFolly], type: Copy) {
from(dependenciesPath ?: tarTree(downloadFolly.dest))
from("src/main/jni/third-party/folly/Android.mk")
include("folly-${FOLLY_VERSION}/folly/**/*", "Android.mk")
eachFile { fname -> fname.path = (fname.path - "folly-${FOLLY_VERSION}/") }
2015-09-16 20:38:42 +03:00
includeEmptyDirs = false
into("$thirdPartyNdkDir/folly")
2015-09-16 20:38:42 +03:00
}
task prepareHermes() {
def hermesPackagePath = findNodeModulePath(projectDir, "hermes-engine")
if (!hermesPackagePath) {
throw new GradleScriptException("Could not find the hermes-engine npm package", null)
}
def hermesAAR = file("$hermesPackagePath/android/hermes-debug.aar")
if (!hermesAAR.exists()) {
throw new GradleScriptException("The hermes-engine npm package is missing \"android/hermes-debug.aar\"", null)
}
def soFiles = zipTree(hermesAAR).matching({ it.include "**/*.so" })
copy {
from soFiles
from "src/main/jni/first-party/hermes/Android.mk"
into "$thirdPartyNdkDir/hermes"
}
}
2015-09-16 20:38:42 +03:00
task downloadGlog(dependsOn: createNativeDepsDirectories, type: Download) {
src("https://github.com/google/glog/archive/v${GLOG_VERSION}.tar.gz")
onlyIfNewer(true)
overwrite(false)
dest(new File(downloadsDir, "glog-${GLOG_VERSION}.tar.gz"))
2015-09-16 20:38:42 +03:00
}
// Prepare glog sources to be compiled, this task will perform steps that normally should've been
2015-09-16 20:38:42 +03:00
// executed by automake. This way we can avoid dependencies on make/automake
task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) {
from(dependenciesPath ?: tarTree(downloadGlog.dest))
from("src/main/jni/third-party/glog/")
include("glog-${GLOG_VERSION}/src/**/*", "Android.mk", "config.h")
2015-09-16 20:38:42 +03:00
includeEmptyDirs = false
filesMatching("**/*.h.in") {
2015-09-16 20:38:42 +03:00
filter(ReplaceTokens, tokens: [
ac_cv_have_unistd_h : "1",
ac_cv_have_stdint_h : "1",
ac_cv_have_systypes_h : "1",
ac_cv_have_inttypes_h : "1",
ac_cv_have_libgflags : "0",
ac_google_start_namespace : "namespace google {",
ac_cv_have_uint16_t : "1",
ac_cv_have_u_int16_t : "1",
ac_cv_have___uint16 : "0",
ac_google_end_namespace : "}",
ac_cv_have___builtin_expect : "1",
ac_google_namespace : "google",
ac_cv___attribute___noinline : "__attribute__ ((noinline))",
ac_cv___attribute___noreturn : "__attribute__ ((noreturn))",
ac_cv___attribute___printf_4_5: "__attribute__((__format__ (__printf__, 4, 5)))"
2015-09-16 20:38:42 +03:00
])
it.path = (it.name - ".in")
2015-09-16 20:38:42 +03:00
}
into("$thirdPartyNdkDir/glog")
doLast {
copy {
from(fileTree(dir: "$thirdPartyNdkDir/glog", includes: ["stl_logging.h", "logging.h", "raw_logging.h", "vlog_is_on.h", "**/src/glog/log_severity.h"]).files)
includeEmptyDirs = false
into("$thirdPartyNdkDir/glog/exported/glog")
}
}
2015-09-16 20:38:42 +03:00
}
// Create Android.mk library module based on jsc from npm
task prepareJSC {
- update to gradle 4.10.1 or high (#23103) Summary: Add suport to gradle 4.10.1 or high! The new version of android studio 3.3 recommendete to update gradle project to 4.10.1 > To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin) >Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio) but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted > WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. > WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. > WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'. > It will be removed at the end of 2019. > For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.) > To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Changelog: ---------- [Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high Pull Request resolved: https://github.com/facebook/react-native/pull/23103 Differential Revision: D13817123 Pulled By: cpojer fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
doLast {
def jscPackagePath = findNodeModulePath(projectDir, "jsc-android")
if (!jscPackagePath) {
throw new GradleScriptException("Could not find the jsc-android npm package", null)
}
def jscDist = file("$jscPackagePath/dist")
if (!jscDist.exists()) {
throw new GradleScriptException("The jsc-android npm package is missing its \"dist\" directory", null)
}
def jscAAR = fileTree(jscDist).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile
- update to gradle 4.10.1 or high (#23103) Summary: Add suport to gradle 4.10.1 or high! The new version of android studio 3.3 recommendete to update gradle project to 4.10.1 > To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin) >Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio) but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted > WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. > WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. > WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'. > It will be removed at the end of 2019. > For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.) > To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Changelog: ---------- [Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high Pull Request resolved: https://github.com/facebook/react-native/pull/23103 Differential Revision: D13817123 Pulled By: cpojer fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" })
def headerFiles = fileTree(jscDist).matching({ it.include "**/include/*.h" })
- update to gradle 4.10.1 or high (#23103) Summary: Add suport to gradle 4.10.1 or high! The new version of android studio 3.3 recommendete to update gradle project to 4.10.1 > To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin) >Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio) but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted > WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. > WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. > WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'. > It will be removed at the end of 2019. > For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.) > To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Changelog: ---------- [Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high Pull Request resolved: https://github.com/facebook/react-native/pull/23103 Differential Revision: D13817123 Pulled By: cpojer fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
copy {
from(soFiles)
from(headerFiles)
from("src/main/jni/third-party/jsc/Android.mk")
- update to gradle 4.10.1 or high (#23103) Summary: Add suport to gradle 4.10.1 or high! The new version of android studio 3.3 recommendete to update gradle project to 4.10.1 > To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin) >Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio) but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted > WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. > WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. > WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'. > It will be removed at the end of 2019. > For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.) > To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Changelog: ---------- [Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high Pull Request resolved: https://github.com/facebook/react-native/pull/23103 Differential Revision: D13817123 Pulled By: cpojer fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
filesMatching("**/*.h", { it.path = "JavaScriptCore/${it.name}" })
includeEmptyDirs(false)
into("$thirdPartyNdkDir/jsc")
- update to gradle 4.10.1 or high (#23103) Summary: Add suport to gradle 4.10.1 or high! The new version of android studio 3.3 recommendete to update gradle project to 4.10.1 > To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin to version 3.3.0 and Gradle to version 4.10.1. [Release notes ](https://developer.android.com/studio/releases/gradle-plugin) >Android plugin 3.2.0 and higher now support building the Android App Bundle—a new upload format that defers APK generation and signing to compatible app stores, such as Google Play. With app bundles, you no longer have to build, sign, and manage multiple APKs, and users get smaller, more optimized downloads. [Learn more](https://developer.android.com/guide/app-bundle/?utm_source=android-studio) but if the upgrade to the new Android gradle many warnings come up, becouse meny things was obsoleted > WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'. > WARNING: API 'variant.getPackageApplication()' is obsolete and has been replaced with 'variant.getPackageApplicationProvider()'. > WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'. > It will be removed at the end of 2019. > For more information, [see ](https://d.android.com/r/tools/task-configuration-avoidance.) > To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display a stack trace. Changelog: ---------- [Android] [Deprecated] - fix warinings obsolete to update to gradle 4.10.1 or high Pull Request resolved: https://github.com/facebook/react-native/pull/23103 Differential Revision: D13817123 Pulled By: cpojer fbshipit-source-id: 9816e20145a5fded2702cf9317cfb6862f3ebd8b
2019-01-25 14:12:51 +03:00
}
2015-09-16 20:38:42 +03:00
}
}
task downloadNdkBuildDependencies {
if (!boostPath) {
dependsOn(downloadBoost)
}
dependsOn(downloadDoubleConversion)
dependsOn(downloadFolly)
dependsOn(downloadGlog)
}
/**
* Finds the path of the installed npm package with the given name using Node's
* module resolution algorithm, which searches "node_modules" directories up to
* the file system root. This handles various cases, including:
*
* - Working in the open-source RN repo:
* Gradle: /path/to/react-native/ReactAndroid
* Node module: /path/to/react-native/node_modules/[package]
*
* - Installing RN as a dependency of an app and searching for hoisted
* dependencies:
* Gradle: /path/to/app/node_modules/react-native/ReactAndroid
* Node module: /path/to/app/node_modules/[package]
*
* - Working in a larger repo (e.g., Facebook) that contains RN:
* Gradle: /path/to/repo/path/to/react-native/ReactAndroid
* Node module: /path/to/repo/node_modules/[package]
*
* The search begins at the given base directory (a File object). The returned
* path is a string.
*/
def findNodeModulePath(baseDir, packageName) {
def basePath = baseDir.toPath().normalize()
// Node's module resolution algorithm searches up to the root directory,
// after which the base path will be null
while (basePath) {
def candidatePath = Paths.get(basePath.toString(), "node_modules", packageName)
if (candidatePath.toFile().exists()) {
return candidatePath.toString()
}
basePath = basePath.getParent()
}
return null
}
2015-09-16 20:38:42 +03:00
def getNdkBuildName() {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
return "ndk-build.cmd"
} else {
return "ndk-build"
}
}
def findNdkBuildFullPath() {
// we allow to provide full path to ndk-build tool
if (hasProperty("ndk.command")) {
return property("ndk.command")
2015-09-16 20:38:42 +03:00
}
// or just a path to the containing directory
if (hasProperty("ndk.path")) {
def ndkDir = property("ndk.path")
2015-09-16 20:38:42 +03:00
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
if (System.getenv("ANDROID_NDK") != null) {
def ndkDir = System.getenv("ANDROID_NDK")
2015-09-16 20:38:42 +03:00
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null
2015-09-16 20:38:42 +03:00
if (ndkDir) {
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
return null
}
def reactNativeDevServerPort() {
def value = project.getProperties().get("reactNativeDevServerPort")
return value != null ? value : "8081"
}
def reactNativeInspectorProxyPort() {
def value = project.getProperties().get("reactNativeInspectorProxyPort")
return value != null ? value : reactNativeDevServerPort()
}
2015-09-16 20:38:42 +03:00
def getNdkBuildFullPath() {
def ndkBuildFullPath = findNdkBuildFullPath()
if (ndkBuildFullPath == null) {
2015-09-16 20:38:42 +03:00
throw new GradleScriptException(
"ndk-build binary cannot be found, check if you've set " +
"\$ANDROID_NDK environment variable correctly or if ndk.dir is " +
"setup in local.properties",
null)
2015-09-16 20:38:42 +03:00
}
if (!new File(ndkBuildFullPath).canExecute()) {
throw new GradleScriptException(
"ndk-build binary " + ndkBuildFullPath + " doesn't exist or isn't executable.\n" +
"Check that the \$ANDROID_NDK environment variable, or ndk.dir in local.properties, is set correctly.\n" +
"(On Windows, make sure you escape backslashes in local.properties or use forward slashes, e.g. C:\\\\ndk or C:/ndk rather than C:\\ndk)",
null)
}
2015-09-16 20:38:42 +03:00
return ndkBuildFullPath
}
def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog, extractAARHeaders, extractJNIFiles)
inputs.dir("$projectDir/../ReactCommon")
inputs.dir("src/main/jni")
inputs.dir("src/main/java/com/facebook/react/modules/blob")
2015-09-16 20:38:42 +03:00
outputs.dir("$buildDir/react-ndk/all")
commandLine(getNdkBuildFullPath(),
"NDK_DEBUG=" + (nativeBuildType.equalsIgnoreCase("debug") ? "1" : "0"),
"NDK_PROJECT_PATH=null",
2015-09-16 20:38:42 +03:00
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
"NDK_OUT=" + temporaryDir,
2015-09-16 20:38:42 +03:00
"NDK_LIBS_OUT=$buildDir/react-ndk/all",
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
"REACT_SRC_DIR=$projectDir/src/main/java/com/facebook/react",
"-C", file("src/main/jni/react/jni").absolutePath,
"--jobs", project.findProperty("jobs") ?: Runtime.runtime.availableProcessors()
)
2015-09-16 20:38:42 +03:00
}
def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) {
ignoreExitValue(true)
errorOutput(new ByteArrayOutputStream())
commandLine(getNdkBuildFullPath(),
"NDK_APPLICATION_MK=$projectDir/src/main/jni/Application.mk",
"THIRD_PARTY_NDK_DIR=$buildDir/third-party-ndk",
"REACT_COMMON_DIR=$projectDir/../ReactCommon",
"-C", file("src/main/jni/react/jni").absolutePath,
"clean")
doLast {
file(AAR_OUTPUT_URL).delete()
println("Deleted aar output dir at ${file(AAR_OUTPUT_URL)}")
}
2015-09-16 20:38:42 +03:00
}
def packageReactNdkLibs = tasks.register("packageReactNdkLibs", Copy) {
dependsOn(buildReactNdkLib)
from("$buildDir/react-ndk/all")
into("$buildDir/react-ndk/exported")
exclude("**/libjsc.so")
exclude("**/libhermes.so")
2015-09-16 20:38:42 +03:00
}
def packageReactNdkLibsForBuck = tasks.register("packageReactNdkLibsForBuck", Copy) {
dependsOn(packageReactNdkLibs)
from("$buildDir/react-ndk/exported")
into("src/main/jni/prebuilt/lib")
}
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
task extractAARHeaders {
doLast {
configurations.extractHeaders.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/headers"
include "**/*.h"
}
}
}
}
task extractJNIFiles {
doLast {
configurations.extractJNI.files.each {
def file = it.absoluteFile
def packageName = file.name.tokenize('-')[0]
copy {
from zipTree(file)
into "$projectDir/src/main/jni/first-party/$packageName/"
include "jni/**/*"
}
}
}
}
2015-09-16 20:38:42 +03:00
android {
compileSdkVersion 29
2015-09-16 20:38:42 +03:00
compileOptions {
sourceCompatibility(JavaVersion.VERSION_1_8)
targetCompatibility(JavaVersion.VERSION_1_8)
}
2015-09-16 20:38:42 +03:00
defaultConfig {
minSdkVersion(19)
targetSdkVersion(28)
versionCode(1)
versionName("1.0")
2015-09-16 20:38:42 +03:00
consumerProguardFiles("proguard-rules.pro")
Inline and fix proguard rules Summary: The original proguard rules are put in the template, which is not very convenient and easy to get wrong. Because new rules get put, people also has two copy paste the rule. And there are also existing project import react native as a dependency. So the best way to keep a android library project proguard rule is to manage the rule itself, using `consumerProguardFiles` like [dagger](https://github.com/JakeWharton/butterknife/blob/46baef6d96e93a1872efa17fdfc1d2af59b36f0c/butterknife/build.gradle#L9) and other android library project. <!-- Required: Write your motivation here. If this PR fixes an issue, type "Fixes #issueNumber" to automatically close the issue when the PR is merged. --> Use RNTester to build the release flavor (now it has bugs https://github.com/facebook/react-native/issues/18460, I keep my change in local for now), after build success, run to check if crash. In the process, I also fix https://github.com/facebook/react-native/issues/12994 and https://github.com/facebook/react-native/issues/6624 by adding the following to proguard rules ```proguard -keep,includedescriptorclasses class com.facebook.react.bridge.** { *; } ``` <!-- Does this PR require a documentation change? Create a PR at https://github.com/facebook/react-native-website and add a link to it here. --> [ANDROID] [ENHANCEMENT and BUGFIX] [Proguard rules] - inline and fix proguard rules . <!-- **INTERNAL and MINOR tagged notes will not be included in the next version's final release notes.** CATEGORY [----------] TYPE [ CLI ] [-------------] LOCATION [ DOCS ] [ BREAKING ] [-------------] [ GENERAL ] [ BUGFIX ] [ {Component} ] [ INTERNAL ] [ ENHANCEMENT ] [ {Filename} ] [ IOS ] [ FEATURE ] [ {Directory} ] |-----------| [ ANDROID ] [ MINOR ] [ {Framework} ] - | {Message} | [----------] [-------------] [-------------] |-----------| EXAMPLES: [IOS] [BREAKING] [FlatList] - Change a thing that breaks other things [ANDROID] [BUGFIX] [TextInput] - Did a thing to TextInput [CLI] [FEATURE] [local-cli/info/info.js] - CLI easier to do things with [DOCS] [BUGFIX] [GettingStarted.md] - Accidentally a thing/word [GENERAL] [ENHANCEMENT] [Yoga] - Added new yoga thing/position [INTERNAL] [FEATURE] [./scripts] - Added thing to script that nobody will see --> Closes https://github.com/facebook/react-native/pull/18461 Differential Revision: D7527533 Pulled By: hramos fbshipit-source-id: 447dbc16983bcfb597187b40c1be3987a8c5a832
2018-04-06 03:26:39 +03:00
buildConfigField("boolean", "IS_INTERNAL_BUILD", "false")
buildConfigField("int", "EXOPACKAGE_FLAGS", "0")
resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort()
resValue "integer", "react_native_inspector_proxy_port", reactNativeInspectorProxyPort()
testApplicationId("com.facebook.react.tests.gradle")
testInstrumentationRunner("androidx.test.runner.AndroidJUnitRunner")
2015-09-16 20:38:42 +03:00
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir("$buildDir/react-ndk/exported")
res.srcDirs = ["src/main/res/devsupport", "src/main/res/shell", "src/main/res/views/modal", "src/main/res/views/uimanager"]
java {
srcDirs = ["src/main/java", "src/main/libraries/soloader/java", "src/main/jni/first-party/fb/jni/java"]
exclude("com/facebook/react/processing")
exclude("com/facebook/react/module/processing")
}
2015-09-16 20:38:42 +03:00
}
tasks.withType(JavaCompile) {
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
compileTask ->
compileTask.dependsOn(packageReactNdkLibs)
2015-09-16 20:38:42 +03:00
}
clean.dependsOn(cleanReactNdkLib)
2015-09-16 20:38:42 +03:00
lintOptions {
abortOnError(false)
2015-09-16 20:38:42 +03:00
}
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
packagingOptions {
exclude("META-INF/NOTICE")
exclude("META-INF/LICENSE")
}
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
configurations {
extractHeaders
extractJNI
}
2015-09-16 20:38:42 +03:00
}
dependencies {
api("com.facebook.infer.annotation:infer-annotation:0.11.2")
api("com.facebook.yoga:proguard-annotations:1.14.1")
api("javax.inject:javax.inject:1")
api("androidx.appcompat:appcompat:1.0.2")
PlatformColor implementations for iOS and Android (#27908) Summary: This Pull Request implements the PlatformColor proposal discussed at https://github.com/react-native-community/discussions-and-proposals/issues/126. The changes include implementations for iOS and Android as well as a PlatformColorExample page in RNTester. Every native platform has the concept of system defined colors. Instead of specifying a concrete color value the app developer can choose a system color that varies in appearance depending on a system theme settings such Light or Dark mode, accessibility settings such as a High Contrast mode, and even its context within the app such as the traits of a containing view or window. The proposal is to add true platform color support to react-native by extending the Flow type `ColorValue` with platform specific color type information for each platform and to provide a convenience function, `PlatformColor()`, for instantiating platform specific ColorValue objects. `PlatformColor(name [, name ...])` where `name` is a system color name on a given platform. If `name` does not resolve to a color for any reason, the next `name` in the argument list will be resolved and so on. If none of the names resolve, a RedBox error occurs. This allows a latest platform color to be used, but if running on an older platform it will fallback to a previous version. The function returns a `ColorValue`. On iOS the values of `name` is one of the iOS [UI Element](https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors) or [Standard Color](https://developer.apple.com/documentation/uikit/uicolor/standard_colors) names such as `labelColor` or `systemFillColor`. On Android the `name` values are the same [app resource](https://developer.android.com/guide/topics/resources/providing-resources) path strings that can be expressed in XML: XML Resource: `@ [<package_name>:]<resource_type>/<resource_name>` Style reference from current theme: `?[<package_name>:][<resource_type>/]<resource_name>` For example: - `?android:colorError` - `?android:attr/colorError` - `?attr/colorPrimary` - `?colorPrimaryDark` - `android:color/holo_purple` - `color/catalyst_redbox_background` On iOS another type of system dynamic color can be created using the `IOSDynamicColor({dark: <color>, light:<color>})` method. The arguments are a tuple containing custom colors for light and dark themes. Such dynamic colors are useful for branding colors or other app specific colors that still respond automatically to system setting changes. Example: `<View style={{ backgroundColor: IOSDynamicColor({light: 'black', dark: 'white'}) }}/>` Other platforms could create platform specific functions similar to `IOSDynamicColor` per the needs of those platforms. For example, macOS has a similar dynamic color type that could be implemented via a `MacDynamicColor`. On Windows custom brushes that tint or otherwise modify a system brush could be created using a platform specific method. ## Changelog [General] [Added] - Added PlatformColor implementations for iOS and Android Pull Request resolved: https://github.com/facebook/react-native/pull/27908 Test Plan: The changes have been tested using the RNTester test app for iOS and Android. On iOS a set of XCTestCase's were added to the Unit Tests. <img width="924" alt="PlatformColor-ios-android" src="https://user-images.githubusercontent.com/30053638/73472497-ff183a80-433f-11ea-90d8-2b04338bbe79.png"> In addition `PlatformColor` support has been added to other out-of-tree platforms such as macOS and Windows has been implemented using these changes: react-native for macOS branch: https://github.com/microsoft/react-native/compare/master...tom-un:tomun/platformcolors react-native for Windows branch: https://github.com/microsoft/react-native-windows/compare/master...tom-un:tomun/platformcolors iOS |Light|Dark| |{F229354502}|{F229354515}| Android |Light|Dark| |{F230114392}|{F230114490}| {F230122700} Reviewed By: hramos Differential Revision: D19837753 Pulled By: TheSavior fbshipit-source-id: 82ca70d40802f3b24591bfd4b94b61f3c38ba829
2020-03-03 02:07:50 +03:00
api("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
api("com.facebook.fresco:fresco:${FRESCO_VERSION}")
api("com.facebook.fresco:imagepipeline-okhttp3:${FRESCO_VERSION}")
api("com.facebook.soloader:soloader:${SO_LOADER_VERSION}")
api("com.google.code.findbugs:jsr305:3.0.2")
api("com.squareup.okhttp3:okhttp:${OKHTTP_VERSION}")
api("com.squareup.okhttp3:okhttp-urlconnection:${OKHTTP_VERSION}")
api("com.squareup.okio:okio:1.15.0")
Migrate to FBJNI (#27729) Summary: This is an incomplete effort to migrate from libfb to libfbjni. This is needed to restore the compatibility with Flipper and other FB Android projects that make use of FBJNI. Effectively, the outcome is that `fbjni` no longer has a checked-in copy here, but instead relies on the public artifacts published at github.com/facebookincubator/fbjni that can be deduplicated at build-time. **A non-exhaustive list of tasks:** * [X] Gradle builds the SDK and RNTester for Android. * [X] Buck build for rntester works in OSS. * [ ] Move from `java-only` release to full `fbjni` release. This requires finding a solution for stripping out `.so` files that the old `Android.mk` insists on including in the final artifacts and will clash with the full distribution. * [ ] Import this and fix potential internal build issues. * [ ] Verify that the changes made to the Hermes integration don't have any unintended consequences. ## Changelog [Android] [Changed] - Migrated from libfb to libfbjni for JNI calls Pull Request resolved: https://github.com/facebook/react-native/pull/27729 Test Plan: - CI is already passing again for Gradle and Buck in OSS. - After applying the following patch, RNTester builds and works with the latest Flipper SDK: ``` diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index b8a6437d7..eac942104 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -170,10 +170,19 @@ dependencies { debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") - debugImplementation("com.facebook.flipper:flipper:0.23.4") { + debugImplementation("com.facebook.flipper:flipper:+") { exclude group:'com.facebook.yoga' - exclude group:'com.facebook.flipper', module: 'fbjni' - exclude group:'com.facebook.litho', module: 'litho-annotations' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-network-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' + } + + debugImplementation("com.facebook.flipper:flipper-fresco-plugin:+") { + exclude group:'com.facebook.yoga' + exclude group:'com.facebook.fbjni' } if (useIntlJsc) { ``` Reviewed By: mdvacca Differential Revision: D19345270 Pulled By: passy fbshipit-source-id: 33811e7f97f44f2ec5999e1c35339909dc4fd3b1
2020-01-21 13:30:57 +03:00
api("com.facebook.fbjni:fbjni-java-only:0.0.3")
extractHeaders("com.facebook.fbjni:fbjni:0.0.2:headers")
extractJNI("com.facebook.fbjni:fbjni:0.0.2")
testImplementation("junit:junit:${JUNIT_VERSION}")
testImplementation("org.powermock:powermock-api-mockito2:${POWERMOCK_VERSION}")
testImplementation("org.powermock:powermock-module-junit4-rule:${POWERMOCK_VERSION}")
testImplementation("org.powermock:powermock-classloading-xstream:${POWERMOCK_VERSION}")
testImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
testImplementation("org.easytesting:fest-assert-core:${FEST_ASSERT_CORE_VERSION}")
testImplementation("org.robolectric:robolectric:${ROBOLECTRIC_VERSION}")
androidTestImplementation(fileTree(dir: "src/main/third-party/java/buck-android-support/", include: ["*.jar"]))
androidTestImplementation("androidx.test:runner:${ANDROIDX_TEST_VERSION}")
androidTestImplementation("androidx.test:rules:${ANDROIDX_TEST_VERSION}")
androidTestImplementation("org.mockito:mockito-core:${MOCKITO_CORE_VERSION}")
2015-09-16 20:38:42 +03:00
}
apply(from: "release.gradle")
OSS Android: architecture.gradle base setup Summary: Introduced `architecture.gradle` that sets up pluggable build-time codegen steps for Gradle so that: * Libraries, including core ReactAndroid, can produce the new architecture codegen (NativeModule **Java** specs in this diff) during build time * Hosting app (e.g. RNTester) can produce its own set of codegen specs separately **Please note that this is still work in progress, hence app templates have not been updated to use it yet.** In order to activate this setup, the env variable `USE_CODEGEN=1` must be set. Eventually, this var will be removed from the logic. With this change, RNTester: * Will see all the generated specs populated in the Gradle build dir, which should be equivalent to the currently [**checked in version**](https://github.com/facebook/react-native/tree/master/ReactAndroid/src/main/java/com/facebook/fbreact/specs). * The specs will compile, but **have not been validated** vs the existing NativeModule .java classes through out the core -- that will be the next step * The specs are under `com.facebook.fbreact.specs.beta` namespace, which will be configurable in the future. `.beta` is added to avoid conflict with the existing files in the repo. ### Is this all we need to enable TurboModule in Android? No. There are a few more pieces needed: * C++ codegen output for JNI layer for each NativeModule spec * The C++ module lookup for TurboModule Manager * The JNI build setup in Gradle for these C++ output * Toggle to enable TurboModule system in the entire app Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D22838581 fbshipit-source-id: d972e2fbb37bdbd3354e72b014fc8bb27a33b9ac
2020-08-01 04:47:45 +03:00
apply(from: "../architecture.gradle");
generateNativeArtifactsFromJavaScript([
enableCodegen: System.getenv("USE_CODEGEN"),
jsRootDir: "${file('../Libraries')}",
])