mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
60 lines
2.2 KiB
Groovy
60 lines
2.2 KiB
Groovy
pluginManagement {
|
|
// Ensure 'node' is on the PATH for all Gradle child processes (e.g. when launched from Android Studio).
|
|
// Android Studio doesn't inherit the shell's PATH, so Homebrew/nvm node isn't found.
|
|
// Modifying a ProcessBuilder's environment() mutates the global ProcessEnvironment.theEnvironment,
|
|
// making 'node' available to all subsequently spawned processes (including Gradle plugins).
|
|
def nodeDir = null
|
|
for (candidate in ["/opt/homebrew/bin/node", "/usr/local/bin/node", System.getenv("HOME") + "/.nvm/current/bin/node"]) {
|
|
if (new File(candidate).exists()) {
|
|
nodeDir = new File(candidate).getParent()
|
|
break
|
|
}
|
|
}
|
|
if (nodeDir != null) {
|
|
def processEnv = new ProcessBuilder().environment()
|
|
def currentPath = processEnv.get("PATH") ?: ""
|
|
if (!currentPath.contains(nodeDir)) {
|
|
processEnv.put("PATH", nodeDir + File.pathSeparator + currentPath)
|
|
}
|
|
}
|
|
def nodeBinary = nodeDir ? nodeDir + "/node" : "node"
|
|
|
|
def reactNativeGradlePlugin = new File(
|
|
providers.exec {
|
|
workingDir(rootDir)
|
|
commandLine(nodeBinary, "--print", "require.resolve('@react-native/gradle-plugin/package.json', { paths: [require.resolve('react-native/package.json')] })")
|
|
}.standardOutput.asText.get().trim()
|
|
).getParentFile().absolutePath
|
|
includeBuild(reactNativeGradlePlugin)
|
|
|
|
def expoPluginsPath = new File(
|
|
providers.exec {
|
|
workingDir(rootDir)
|
|
commandLine(nodeBinary, "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })")
|
|
}.standardOutput.asText.get().trim(),
|
|
"../android/expo-gradle-plugin"
|
|
).absolutePath
|
|
includeBuild(expoPluginsPath)
|
|
}
|
|
|
|
plugins {
|
|
id("com.facebook.react.settings")
|
|
id("expo-autolinking-settings")
|
|
}
|
|
|
|
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
|
|
if (System.getenv('EXPO_USE_COMMUNITY_AUTOLINKING') == '1') {
|
|
ex.autolinkLibrariesFromCommand()
|
|
} else {
|
|
ex.autolinkLibrariesFromCommand(expoAutolinking.rnConfigCommand)
|
|
}
|
|
}
|
|
expoAutolinking.useExpoModules()
|
|
|
|
rootProject.name = 'example-expo-53'
|
|
|
|
expoAutolinking.useExpoVersionCatalog()
|
|
|
|
include ':app'
|
|
includeBuild(expoAutolinking.reactNativeGradlePlugin)
|