@@ -45,6 +45,10 @@ def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
45
45
// Setup build type for NDK, supported values: {debug, release}
46
46
def nativeBuildType = System . getenv(" NATIVE_BUILD_TYPE" ) ?: " release"
47
47
48
+ // We put the publishing version from gradle.properties inside ext. so other
49
+ // subprojects can access it as well.
50
+ ext. publishing_version = VERSION_NAME
51
+
48
52
task createNativeDepsDirectories {
49
53
downloadsDir. mkdirs()
50
54
thirdPartyNdkDir. mkdirs()
@@ -127,24 +131,6 @@ final def prepareLibevent = tasks.register("prepareLibevent", PrepareLibeventTas
127
131
it. outputDir. set(new File (thirdPartyNdkDir, " libevent" ))
128
132
}
129
133
130
- task prepareHermes (dependsOn : createNativeDepsDirectories, type : Copy ) {
131
- def hermesPackagePath = findNodeModulePath(projectDir, " hermes-engine" )
132
- if (! hermesPackagePath) {
133
- throw new GradleScriptException (" Could not find the hermes-engine npm package" , null )
134
- }
135
-
136
- def hermesAAR = file(" $hermesPackagePath /android/hermes-debug.aar" )
137
- if (! hermesAAR. exists()) {
138
- throw new GradleScriptException (" The hermes-engine npm package is missing \" android/hermes-debug.aar\" " , null )
139
- }
140
-
141
- def soFiles = zipTree(hermesAAR). matching({ it. include " **/*.so" })
142
-
143
- from soFiles
144
- from " src/main/jni/first-party/hermes/Android.mk"
145
- into " $thirdPartyNdkDir /hermes"
146
- }
147
-
148
134
task downloadGlog (dependsOn : createNativeDepsDirectories, type : Download ) {
149
135
src(" https://github.com/google/glog/archive/v${ GLOG_VERSION} .tar.gz" )
150
136
onlyIfNewer(true )
@@ -259,18 +245,11 @@ final def extractNativeDependencies = tasks.register('extractNativeDependencies'
259
245
it. extractHeadersConfiguration. setFrom(configurations. extractHeaders)
260
246
it. extractJniConfiguration. setFrom(configurations. extractJNI)
261
247
it. baseOutputDir = project. file(" src/main/jni/first-party/" )
262
- // Sadly this task as an output folder path that is directly dependent on
263
- // the task input (i.e. src/main/jni/first-party/<package-name>/...
264
- // This means that this task is using the parent folder (first-party/) as
265
- // @OutputFolder. The `prepareHermes` task will also output inside that
266
- // folder and if the two tasks happen to be inside the same run, we want
267
- // `extractNativeDependencies` to run after `prepareHermes` to do not
268
- // invalidate the input/output calculation for this task.
269
- it. mustRunAfter(prepareHermes)
270
248
}
271
249
272
250
task installArchives {
273
251
dependsOn(" publishReleasePublicationToNpmRepository" )
252
+ dependsOn(" :ReactAndroid:hermes-engine:installArchives" )
274
253
}
275
254
276
255
// Creating sources with comments
@@ -314,6 +293,7 @@ android {
314
293
" REACT_COMMON_DIR=$projectDir /../ReactCommon" ,
315
294
" REACT_GENERATED_SRC_DIR=$buildDir /generated/source" ,
316
295
" REACT_SRC_DIR=$projectDir /src/main/java/com/facebook/react" ,
296
+ " APP_STL=c++_shared" ,
317
297
" -j${ ndkBuildJobs()} "
318
298
319
299
if (Os . isFamily(Os . FAMILY_MAC )) {
@@ -333,7 +313,7 @@ android {
333
313
}
334
314
}
335
315
336
- preBuild. dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFmt, prepareFolly, prepareGlog, prepareLibevent, extractNativeDependencies)
316
+ preBuild. dependsOn(prepareJSC, prepareBoost, prepareDoubleConversion, prepareFmt, prepareFolly, prepareGlog, prepareLibevent, extractNativeDependencies)
337
317
preBuild. dependsOn(" generateCodegenArtifactsFromSchema" )
338
318
339
319
sourceSets. main {
@@ -366,6 +346,10 @@ android {
366
346
extractJNI
367
347
javadocDeps. extendsFrom api
368
348
}
349
+
350
+ buildFeatures {
351
+ prefab true
352
+ }
369
353
}
370
354
371
355
dependencies {
@@ -388,6 +372,15 @@ dependencies {
388
372
extractHeaders(" com.facebook.fbjni:fbjni:0.2.2:headers" )
389
373
extractJNI(" com.facebook.fbjni:fbjni:0.2.2" )
390
374
375
+ // It's up to the consumer to decide if hermes should be included or not.
376
+ // Therefore hermes-engine is a compileOnly dependency.
377
+ // Moreover, you can toggle where to get the dependency with `buildHermesFromSource`.
378
+ if (project. getProperties(). getOrDefault(" buildHermesFromSource" , " false" ). toBoolean()) {
379
+ compileOnly(project(" :ReactAndroid:hermes-engine" ))
380
+ } else {
381
+ compileOnly(" com.facebook.react:hermes-engine:${ VERSION_NAME} " )
382
+ }
383
+
391
384
javadocDeps(" com.squareup:javapoet:1.13.0" )
392
385
393
386
testImplementation(" junit:junit:${ JUNIT_VERSION} " )
0 commit comments