Skip to content
Branch: master
Find file Copy path
Find file Copy path
5 contributors

Users who have contributed to this file

@sjchmiela @esamelson @rodneyrehm @jesseruder @janicduplessis
68 lines (52 sloc) 2.36 KB
// Gradle script for detached apps.
void runBefore(String dependentTaskName, Task task) {
Task dependentTask = tasks.findByPath(dependentTaskName);
if (dependentTask != null) {
dependentTask.dependsOn task
afterEvaluate {
def expoRoot = file("../../")
def inputExcludes = ["android/**", "ios/**"]
task exponentPrebuildStep(type: Exec) {
workingDir expoRoot
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine "cmd", "/c", ".\\node_modules\\expokit\\detach-scripts\\run-exp.bat", "prepare-detached-build", "--platform", "android", expoRoot
} else {
commandLine "./node_modules/expokit/detach-scripts/", "prepare-detached-build", "--platform", "android", expoRoot
runBefore("preBuild", exponentPrebuildStep)
// Based on
android.applicationVariants.each { variant ->
def folderName =
def targetName = folderName.capitalize()
def assetsDir = file("$buildDir/intermediates/merged_assets/${folderName}/out")
// Bundle task name for variant
def bundleExpoAssetsTaskName = "bundle${targetName}ExpoAssets"
def currentBundleTask = tasks.create(
name: bundleExpoAssetsTaskName,
type: Exec) {
description = "Expo bundle assets for ${targetName}."
// Create dirs if they are not there (e.g. the "clean" task just ran)
doFirst {
// Set up inputs and outputs so gradle can cache the result
inputs.files fileTree(dir: expoRoot, excludes: inputExcludes)
outputs.dir assetsDir
// Set up the call to exp
workingDir expoRoot
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine("cmd", "/c", ".\\node_modules\\expokit\\detach-scripts\\run-exp.bat", "bundle-assets", expoRoot, "--platform", "android", "--dest", assetsDir)
} else {
commandLine("./node_modules/expokit/detach-scripts/", "bundle-assets", expoRoot, "--platform", "android", "--dest", assetsDir)
enabled targetName.toLowerCase().contains("release") || targetName.toLowerCase().contains("prod")
runBefore("process${targetName}Resources", currentBundleTask)
You can’t perform that action at this time.