From 040502b5d96207473701cb676caa276af7b2ae79 Mon Sep 17 00:00:00 2001 From: Kudo Chien Date: Tue, 23 Apr 2019 02:18:58 -0700 Subject: [PATCH] Fix jsc-android not found if building from source (#24547) Summary: If an app [builds from RN source](https://facebook.github.io/react-native/docs/building-from-source), there was an error for jsc-android not found. It is a side effect of my previous [JSC as node dependency change](https://github.com/facebook/react-native/commit/8e375850de73d1b998a83279e6c4ba238867a453) For building from RN source case, the jsc-android is located at `/path/to/app/node_modules/jsc-android`. Original gradle task will try to find it at `/path/to/app/node_modules/react-native/ReactAndroid/../node_modules/jsc-android`, as ReactAndroid project path was being override inside node_modules. The change fixes the building from source case. N/A This change does not need to publish into changelog, as it is a master branch building fix. Pull Request resolved: https://github.com/facebook/react-native/pull/24547 Differential Revision: D15044703 Pulled By: cpojer fbshipit-source-id: a7d824b1a14064d46c4a2ec9ea28255179174c83 --- ReactAndroid/build.gradle | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index d79a9b9bafd..74b1d50c998 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -136,11 +136,16 @@ task prepareGlog(dependsOn: dependenciesPath ? [] : [downloadGlog], type: Copy) // Create Android.mk library module based on jsc from npm task prepareJSC { doLast { - def jscPackageRoot = fileTree("$projectDir/../node_modules/jsc-android/dist") - def jscAAR = jscPackageRoot.matching({ it.include "**/android-jsc/**/*.aar" }).singleFile + def jscPackageRoot = file("$projectDir/../node_modules/jsc-android/dist") + if (!jscPackageRoot.exists()) { + // For an app to build from RN source, the jsc-android is located at /path/to/app/node_modules + // and $projectDir may located at /path/to/app/node_modules/react-native/ReactAndroid + jscPackageRoot = file("$projectDir/../../jsc-android/dist") + } + def jscAAR = fileTree(jscPackageRoot).matching({ it.include "**/android-jsc/**/*.aar" }).singleFile def soFiles = zipTree(jscAAR).matching({ it.include "**/*.so" }) - def headerFiles = jscPackageRoot.matching({ it.include "**/include/*.h" }) + def headerFiles = fileTree(jscPackageRoot).matching({ it.include "**/include/*.h" }) copy { from(soFiles)