同步应用代码并排除 SDK 交付目录
This commit is contained in:
1 parent
145ec23526
commit
20c0fcf1f4
6 files changed
+63
-5
No files matched your search
@@ -2,6 +2,8 @@ apply plugin: "com.android.application"
|
||||
apply plugin: "org.jetbrains.kotlin.android"
|
||||
apply plugin: "com.facebook.react"
|
||||
|
||||
apply from: rootProject.file("node.gradle")
|
||||
|
||||
/**
|
||||
* This is the configuration block to customize your React Native Android app.
|
||||
* By default you don't need to apply any configuration, just uncomment the lines you need.
|
||||
@@ -26,6 +28,7 @@ react {
|
||||
/* Bundling */
|
||||
// A list containing the node command and its flags. Default is just 'node'.
|
||||
// nodeExecutableAndArgs = ["node"]
|
||||
nodeExecutableAndArgs = [resolveNodeExecutable()]
|
||||
//
|
||||
// The command to run when bundling. By default is 'bundle'
|
||||
// bundleCommand = "ram-bundle"
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
def parseNodeVersion = { String value ->
|
||||
value.replaceFirst("^v", "")
|
||||
.tokenize(".")
|
||||
.collect { part ->
|
||||
def matcher = part =~ /\d+/
|
||||
matcher.find() ? matcher.group().toInteger() : 0
|
||||
}
|
||||
}
|
||||
|
||||
ext.resolveNodeExecutable = {
|
||||
def fromEnv = System.getenv("NODE_BINARY")
|
||||
if (fromEnv != null && !fromEnv.trim().isEmpty()) {
|
||||
return fromEnv.trim()
|
||||
}
|
||||
|
||||
def home = System.getProperty("user.home")
|
||||
def candidates = []
|
||||
def nvmVersionsDir = new File(home, ".nvm/versions/node")
|
||||
|
||||
if (nvmVersionsDir.isDirectory()) {
|
||||
def versionDirs = nvmVersionsDir.listFiles()?.findAll {
|
||||
new File(it, "bin/node").canExecute()
|
||||
} ?: []
|
||||
|
||||
versionDirs.sort { a, b ->
|
||||
def aVersion = parseNodeVersion(a.name)
|
||||
def bVersion = parseNodeVersion(b.name)
|
||||
for (int i = 0; i < Math.max(aVersion.size(), bVersion.size()); i++) {
|
||||
def aPart = i < aVersion.size() ? aVersion[i] : 0
|
||||
def bPart = i < bVersion.size() ? bVersion[i] : 0
|
||||
if (aPart != bPart) {
|
||||
return bPart <=> aPart
|
||||
}
|
||||
}
|
||||
return b.name <=> a.name
|
||||
}.each {
|
||||
candidates.add(new File(it, "bin/node").absolutePath)
|
||||
}
|
||||
}
|
||||
|
||||
candidates.addAll([
|
||||
"${home}/.nvm/current/bin/node",
|
||||
"/opt/homebrew/bin/node",
|
||||
"/usr/local/bin/node"
|
||||
])
|
||||
|
||||
return candidates.find { new File(it).canExecute() } ?: "node"
|
||||
}
|
||||
@@ -1,6 +1,12 @@
|
||||
pluginManagement { includeBuild("../node_modules/@react-native/gradle-plugin") }
|
||||
plugins { id("com.facebook.react.settings") }
|
||||
extensions.configure(com.facebook.react.ReactSettingsExtension){ ex -> ex.autolinkLibrariesFromCommand() }
|
||||
apply from: new File(settingsDir, "node.gradle")
|
||||
|
||||
def nodeExecutable = resolveNodeExecutable()
|
||||
def reactNativeCli = new File(settingsDir, "../node_modules/@react-native-community/cli/build/bin.js")
|
||||
extensions.configure(com.facebook.react.ReactSettingsExtension) { ex ->
|
||||
ex.autolinkLibrariesFromCommand([nodeExecutable, reactNativeCli.absolutePath, "config"])
|
||||
}
|
||||
rootProject.name = 'dfuapp'
|
||||
include ':app'
|
||||
includeBuild('../node_modules/@react-native/gradle-plugin')
|
||||
Reference in new issue
Block a user