Skip to content

Commit a4585d8

Browse files
committed
[android] Support caching prebuilt hermes-engine
1 parent 9ffb87f commit a4585d8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

ReactAndroid/build.gradle

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,12 @@ def boostPath = dependenciesPath ?: System.getenv("REACT_NATIVE_BOOST_PATH")
5151
// Setup build type for NDK, supported values: {debug, release}
5252
def nativeBuildType = System.getenv("NATIVE_BUILD_TYPE") ?: "release"
5353

54+
def prebuiltHermesDir = findProperty("expo.prebuiltHermesDir") ?: file("${rootDir}/prebuiltHermes")
55+
def prebuiltHermesVersion = file("${prebuiltHermesDir}/.hermesversion").exists() ? file("${prebuiltHermesDir}/.hermesversion").text : null
56+
def currentHermesVersion = file("${project(':ReactAndroid').projectDir}/../sdks/.hermesversion").exists() ? file("${project(':ReactAndroid').projectDir}/../sdks/.hermesversion").text : null
57+
def buildHermesSource = currentHermesVersion != prebuiltHermesVersion
58+
logger.info(":ReactAndroid - buildHermesSource[${buildHermesSource}]")
59+
5460
// We put the publishing version from gradle.properties inside ext. so other
5561
// subprojects can access it as well.
5662
ext.publishing_version = VERSION_NAME
@@ -403,7 +409,12 @@ dependencies {
403409

404410
// It's up to the consumer to decide if hermes should be included or not.
405411
// Therefore hermes-engine is a compileOnly dependency.
406-
compileOnly(project(":ReactAndroid:hermes-engine"))
412+
if (!buildHermesSource) {
413+
debugCompileOnly(files("${prebuiltHermesDir}/hermes-engine-debug.aar"))
414+
releaseCompileOnly(files("${prebuiltHermesDir}/hermes-engine-release.aar"))
415+
} else {
416+
compileOnly(project(":ReactAndroid:hermes-engine"))
417+
}
407418

408419
testImplementation("junit:junit:${JUNIT_VERSION}")
409420
testImplementation("org.assertj:assertj-core:${ASSERTJ_VERSION}")

0 commit comments

Comments
 (0)