From 3d2185203be1b0f3550a540099f968c067ce817d Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Tue, 16 Aug 2022 03:20:16 -0700 Subject: [PATCH] Do not store .cpp/.h files inside src/main/java - mapbuffer Summary: Currently we expose native code (.h, .cpp) inside the src/main/java folder. This is making impossible for users on New Architecture to open the project inside Android Studio. The problem is that the src/main/java is reserved to Java/Kotlin sources only. AGP 7.2 also removed support for mixed source roots: https://developer.android.com/studio/releases/gradle-plugin#duplicate-content-roots This is essentially forcing users to write Java code without any autocompletion as all the React Native Java classes are considered C++ files. I'm addressing this issue folder by folder by moving them from ReactAndroid/src/main/java/com/facebook/... to ReactAndroid/src/main/jni/react/... This is the diff for mapbuffer Changelog: [Internal] [Changed] - Do not store .cpp/.h files inside src/main/java - mapbuffer Reviewed By: cipolleschi Differential Revision: D38699253 fbshipit-source-id: c1c8f8693b6da4e3428f8f280e1ca4d5c5d0f853 --- .../src/main/java/com/facebook/react/common/mapbuffer/BUCK | 2 +- .../com/facebook/react/common/mapbuffer/ReadableMapBuffer.kt | 2 +- ReactAndroid/src/main/jni/CMakeLists.txt | 2 +- .../react/common/mapbuffer/jni => jni/react/mapbuffer}/BUCK | 0 .../common/mapbuffer/jni => jni/react/mapbuffer}/CMakeLists.txt | 0 .../react/mapbuffer}/react/common/mapbuffer/.clang-tidy | 0 .../mapbuffer}/react/common/mapbuffer/JReadableMapBuffer.cpp | 0 .../mapbuffer}/react/common/mapbuffer/JReadableMapBuffer.h | 0 .../mapbuffer}/react/common/mapbuffer/JWritableMapBuffer.cpp | 0 .../mapbuffer}/react/common/mapbuffer/JWritableMapBuffer.h | 0 .../react/mapbuffer}/react/common/mapbuffer/OnLoad.cpp | 0 ReactCommon/react/utils/BUCK | 2 +- 12 files changed, 4 insertions(+), 4 deletions(-) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/BUCK (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/CMakeLists.txt (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/.clang-tidy (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/JReadableMapBuffer.cpp (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/JReadableMapBuffer.h (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/JWritableMapBuffer.cpp (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/JWritableMapBuffer.h (100%) rename ReactAndroid/src/main/{java/com/facebook/react/common/mapbuffer/jni => jni/react/mapbuffer}/react/common/mapbuffer/OnLoad.cpp (100%) diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/BUCK b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/BUCK index daa264d3ba..cf73290ace 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/BUCK @@ -22,7 +22,7 @@ rn_android_library( deps = [ FBJNI_TARGET, react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"), - react_native_target("java/com/facebook/react/common/mapbuffer/jni:jni"), + react_native_target("jni/react/mapbuffer:jni"), react_native_dep("libraries/fbjni:java"), react_native_dep("third-party/android/androidx:annotation"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/ReadableMapBuffer.kt b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/ReadableMapBuffer.kt index e1bef54ad1..744a9ee15a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/ReadableMapBuffer.kt +++ b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/ReadableMapBuffer.kt @@ -17,7 +17,7 @@ import javax.annotation.concurrent.NotThreadSafe /** * Read-only implementation of the [MapBuffer], imported from C++ environment. Use - * ` to create it. + * ` to create it. * * See [MapBuffer] documentation for more details */ diff --git a/ReactAndroid/src/main/jni/CMakeLists.txt b/ReactAndroid/src/main/jni/CMakeLists.txt index d5f08b71da..d23049148d 100644 --- a/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/ReactAndroid/src/main/jni/CMakeLists.txt @@ -98,7 +98,7 @@ add_react_android_subdir(src/main/jni/react/reactperflogger) add_react_android_subdir(src/main/jni/react/jscexecutor) add_react_android_subdir(src/main/java/com/facebook/react/turbomodule/core/jni) add_react_android_subdir(src/main/jni/react/uimanager) -add_react_android_subdir(src/main/java/com/facebook/react/common/mapbuffer/jni) +add_react_android_subdir(src/main/jni/react/mapbuffer) add_react_android_subdir(src/main/java/com/facebook/react/fabric/jni) add_react_android_subdir(src/main/java/com/facebook/react/modules/blob/jni) add_react_android_subdir(src/main/jni/react/hermes/reactexecutor) diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK b/ReactAndroid/src/main/jni/react/mapbuffer/BUCK similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK rename to ReactAndroid/src/main/jni/react/mapbuffer/BUCK diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/CMakeLists.txt b/ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/CMakeLists.txt rename to ReactAndroid/src/main/jni/react/mapbuffer/CMakeLists.txt diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/.clang-tidy b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/.clang-tidy similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/.clang-tidy rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/.clang-tidy diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JReadableMapBuffer.cpp b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JReadableMapBuffer.cpp similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JReadableMapBuffer.cpp rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JReadableMapBuffer.cpp diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JReadableMapBuffer.h b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JReadableMapBuffer.h similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JReadableMapBuffer.h rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JReadableMapBuffer.h diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JWritableMapBuffer.cpp b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JWritableMapBuffer.cpp similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JWritableMapBuffer.cpp rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JWritableMapBuffer.cpp diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JWritableMapBuffer.h b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JWritableMapBuffer.h similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/JWritableMapBuffer.h rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/JWritableMapBuffer.h diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/OnLoad.cpp b/ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp similarity index 100% rename from ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/react/common/mapbuffer/OnLoad.cpp rename to ReactAndroid/src/main/jni/react/mapbuffer/react/common/mapbuffer/OnLoad.cpp diff --git a/ReactCommon/react/utils/BUCK b/ReactCommon/react/utils/BUCK index 85b786d15c..bc2b70d745 100644 --- a/ReactCommon/react/utils/BUCK +++ b/ReactCommon/react/utils/BUCK @@ -36,7 +36,7 @@ rn_xplat_cxx_library( ), compiler_flags_pedantic = True, fbandroid_deps = [ - react_native_target("java/com/facebook/react/common/mapbuffer/jni:jni"), + react_native_target("jni/react/mapbuffer:jni"), react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS,