Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lazy configure ReactAndroid gradle tasks #26314

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,14 @@ def findNdkBuildFullPath() {
def ndkDir = property("ndk.path")
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}

if (System.getenv("ANDROID_NDK") != null) {
gengjiawen marked this conversation as resolved.
Show resolved Hide resolved
def ndkDir = System.getenv("ANDROID_NDK")
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
def ndkDir = android.hasProperty("plugin") ? android.plugin.ndkFolder :
plugins.getPlugin("com.android.library").hasProperty("sdkHandler") ?
plugins.getPlugin("com.android.library").sdkHandler.getNdkFolder() :
android.ndkDirectory ? android.ndkDirectory.absolutePath : null

def ndkDir = android.ndkDirectory ? android.ndkDirectory.absolutePath : null

if (ndkDir) {
return new File(ndkDir, getNdkBuildName()).getAbsolutePath()
}
Expand Down Expand Up @@ -253,7 +253,8 @@ def getNdkBuildFullPath() {
return ndkBuildFullPath
}

task buildReactNdkLib(dependsOn: [prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog], type: Exec) {
def buildReactNdkLib = tasks.register("buildReactNdkLib", Exec) {
dependsOn(prepareJSC, prepareHermes, prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog)
inputs.dir("$projectDir/../ReactCommon")
inputs.dir("src/main/jni")
outputs.dir("$buildDir/react-ndk/all")
Expand All @@ -271,7 +272,7 @@ task buildReactNdkLib(dependsOn: [prepareJSC, prepareHermes, prepareBoost, prepa
)
}

task cleanReactNdkLib(type: Exec) {
def cleanReactNdkLib = tasks.register("cleanReactNdkLib", Exec) {
ignoreExitValue(true)
errorOutput(new ByteArrayOutputStream())
commandLine(getNdkBuildFullPath(),
Expand All @@ -286,14 +287,16 @@ task cleanReactNdkLib(type: Exec) {
}
}

task packageReactNdkLibs(dependsOn: buildReactNdkLib, type: Copy) {
def packageReactNdkLibs = tasks.register("packageReactNdkLibs", Copy) {
dependsOn(buildReactNdkLib)
from("$buildDir/react-ndk/all")
into("$buildDir/react-ndk/exported")
exclude("**/libjsc.so")
exclude("**/libhermes.so")
}

task packageReactNdkLibsForBuck(dependsOn: packageReactNdkLibs, type: Copy) {
def packageReactNdkLibsForBuck = tasks.register("packageReactNdkLibsForBuck", Copy) {
dependsOn(packageReactNdkLibs)
from("$buildDir/react-ndk/exported")
into("src/main/jni/prebuilt/lib")
}
Expand Down