cli
cli copied to clipboard
feat: allow configurable js root for android
Summary:
Currently, it is impossible to set up a React Native project where the Android project folder is not nested inside of the JavaScript project folder. I want to set up my project so that the two are side-by-side, like this:
android <-- Android project goes here
ios
shared/react <-- JavaScript project goes here
shared/rust
To accomplish this, I created a reactNative
Gradle extension, so that the end user can configure the location of their JS project like this:
apply from: file("../../shared/react/node_modules/@react-native-community/cli-platform-android/native_modules.gradle");
reactNative {
root = file "../../shared/react"
}
applyNativeModulesAppBuildGradle(project)
Test Plan:
In order to get this to work, I modified native_modules.gradle
as seen in this PR, then I made a symlink from shared/react/android
to the android
directory so that the RN CLI would detect the configuration properly when queried. I'm not sure how I would write unit tests for something like this, but it works for me.
Hey,
I am not sure I understand the issue here, so I will need extra time clarifying! Thanks in advance!
Currently, it is impossible to set up a React Native project where the Android project folder is not nested inside of the JavaScript project folder
AFAIK, Android project is never nested inside a JavaScript folder, the structure by default is:
- android
- ios
- src/<your_js_goes_here>
- package.json
If you are talking about placing android
folder outside of your project completely, then I am afraid this is not supported and unlikely to be supported - you may run into other strange side errors that we are not covering at this point.
What's more, I think you can already set location of your project by simply providing a correct path to native_modules.gradle
. Everything else is resolved correctly.
I would need to understand what error you're solving with a custom root
first, before moving forward with this PR! Thank you.
There hasn't been any activity on this pull request in the past 3 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 7 days.