Skip to content

Commit

Permalink
Create a cleanAll Top Level Gradle task.
Browse files Browse the repository at this point in the history
Summary:
This task is supposed to really clean all the files that are generated
as part of a build and bring you to a clean state.

Changelog:
[Internal] [Changed] - Create a `cleanAll` Top Level Gradle task.

Reviewed By: ShikaSD

Differential Revision: D32649942

fbshipit-source-id: 20b72ad4e1c0ef046aaaba94e2331176dca49abf
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 30, 2021
1 parent 040e72e commit fab4752
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
13 changes: 13 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,16 @@ allprojects {
ext["ANDROID_NDK_PATH"] = System.getenv("ANDROID_NDK")
}
}

tasks.register("cleanAll", Delete::class.java) {
description = "Remove all the build files and intermediate build outputs"
dependsOn(gradle.includedBuild("react-native-gradle-plugin").task(":clean"))
delete(allprojects.map { it.buildDir })
delete(rootProject.file("./ReactAndroid/.cxx"))
delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/"))
delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/"))
delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/x86/"))
delete(rootProject.file("./ReactAndroid/src/main/jni/prebuilt/lib/x86_64/"))
delete(rootProject.file("./packages/react-native-codegen/lib"))
delete(rootProject.file("./packages/rn-tester/android/app/.cxx"))
}
14 changes: 0 additions & 14 deletions packages/rn-tester/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -300,26 +300,12 @@ if (enableCodegen) {
into("$buildDir/react-ndk/exported")
}

def cleanProjectNdkBuild = tasks.register("cleanProjectNdkBuild", Exec) {
ignoreExitValue(true)
tasks.forEach {
t ->
if (t.name.startsWith("externalNativeBuildClean")) {
dependsOn(t);
}
}
// This .cxx folder may cause stale ndkBuild configuration.
// See https://stackoverflow.com/a/58288851.
commandLine("rm", "-rf", "$projectDir/.cxx")
}

afterEvaluate {
configureNdkBuildRelease.dependsOn(packageReactReleaseNdkLibs)
preHermesReleaseBuild.dependsOn(packageReactReleaseNdkLibs)
preJscReleaseBuild.dependsOn(packageReactReleaseNdkLibs)
configureNdkBuildDebug.dependsOn(packageReactDebugNdkLibs)
preHermesDebugBuild.dependsOn(packageReactDebugNdkLibs)
preJscDebugBuild.dependsOn(packageReactDebugNdkLibs)
clean.dependsOn(cleanProjectNdkBuild)
}
}

0 comments on commit fab4752

Please sign in to comment.