@@ -42,6 +42,28 @@ def resolveReactNativeDirectory() {
42
42
)
43
43
}
44
44
45
+ def resolveReactNativeWorkletsDirectory () {
46
+ def reactNativeWorkletsLocation = safeAppExtGet(" REACT_NATIVE_WORKLETS_NODE_MODULES_DIR" , null )
47
+ if (reactNativeWorkletsLocation != null ) {
48
+ return file(reactNativeWorkletsLocation)
49
+ }
50
+
51
+ // Fallback to node resolver for custom directory structures like monorepos.
52
+ def reactNativeWorkletsPackage = file(
53
+ providers. exec {
54
+ workingDir(rootDir)
55
+ commandLine(" node" , " --print" , " require.resolve('react-native-worklets/package.json')" )
56
+ }. standardOutput. asText. get(). trim()
57
+ )
58
+ if (reactNativeWorkletsPackage. exists()) {
59
+ return reactNativeWorkletsPackage. parentFile
60
+ }
61
+
62
+ throw new GradleException (
63
+ " [Reanimated] Unable to resolve react-native-worklets location in node_modules. You should set project extension property (in `app/build.gradle`) named `REACT_NATIVE_WORKLETS_NODE_MODULES_DIR` with the path to react-native-worklets in node_modules."
64
+ )
65
+ }
66
+
45
67
def getReactNativeMinorVersion () {
46
68
def reactNativeRootDir = resolveReactNativeDirectory()
47
69
def reactProperties = new Properties ()
@@ -102,6 +124,7 @@ if (isNewArchitectureEnabled()) {
102
124
}
103
125
104
126
def reactNativeRootDir = resolveReactNativeDirectory()
127
+ def reactNativeWorkletsRootDir = resolveReactNativeWorkletsDirectory()
105
128
def REACT_NATIVE_MINOR_VERSION = getReactNativeMinorVersion()
106
129
def REANIMATED_VERSION = getReanimatedVersion()
107
130
def IS_NEW_ARCHITECTURE_ENABLED = isNewArchitectureEnabled()
@@ -181,6 +204,7 @@ android {
181
204
" -DREACT_NATIVE_MINOR_VERSION=${ REACT_NATIVE_MINOR_VERSION} " ,
182
205
" -DANDROID_TOOLCHAIN=clang" ,
183
206
" -DREACT_NATIVE_DIR=${ toPlatformFileString(reactNativeRootDir.path)} " ,
207
+ " -DREACT_NATIVE_WORKLETS_DIR=${ toPlatformFileString(reactNativeWorkletsRootDir.path)} " ,
184
208
" -DIS_REANIMATED_EXAMPLE_APP=${ IS_REANIMATED_EXAMPLE_APP} " ,
185
209
" -DREANIMATED_PROFILING=${ REANIMATED_PROFILING} " ,
186
210
" -DREANIMATED_VERSION=${ REANIMATED_VERSION} " ,
@@ -324,3 +348,12 @@ dependencies {
324
348
}
325
349
326
350
preBuild. dependsOn(prepareReanimatedHeadersForPrefabs)
351
+
352
+ if (project != rootProject) {
353
+ evaluationDependsOn(" :react-native-worklets" )
354
+
355
+ afterEvaluate {
356
+ tasks. getByName(" externalNativeBuildDebug" ). dependsOn(findProject(" :react-native-worklets" ). tasks. getByName(" externalNativeBuildDebug" ))
357
+ tasks. getByName(" externalNativeBuildRelease" ). dependsOn(findProject(" :react-native-worklets" ). tasks. getByName(" externalNativeBuildRelease" ))
358
+ }
359
+ }
0 commit comments