Skip to content

Commit e8d513c

Browse files
Add clean task workaround for malformed build dir
1 parent 7f94aa0 commit e8d513c

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

app/build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,3 +176,25 @@ tasks.named("clean") {
176176
delete(new File(projectDir, ".cxx"))
177177
}
178178
}
179+
180+
// This is needed because task "clean" depends on these tasks:
181+
//:app:externalNativeBuildCleanLiteDebug
182+
//:app:externalNativeBuildCleanLiteRelease
183+
//:app:externalNativeBuildCleanProDebug
184+
//:app:externalNativeBuildCleanProRelease
185+
// And these tasks expect to find build/conan/[ABI]/conan_toolchain.cmake files
186+
//
187+
// If build folder is malformed, we can't run `gradle clean` without this workaround.
188+
// This is because we supply our (conan's) CMAKE_TOOLCHAIN_FILE.
189+
// This workaround removes these "clean" task dependencies if conan_toolchain.cmake is not found (malformed build dir)
190+
project.afterEvaluate {
191+
["armv7", "armv8", "x86", "x86_64"].each { String arch ->
192+
if (!new File(projectDir, 'build/conan/' + arch + 'conan_toolchain.cmake').exists()) {
193+
def cleanTask = tasks.named("clean").get()
194+
cleanTask.dependsOn -= tasks.named('externalNativeBuildCleanLiteDebug')
195+
cleanTask.dependsOn -= tasks.named('externalNativeBuildCleanLiteRelease')
196+
cleanTask.dependsOn -= tasks.named('externalNativeBuildCleanProDebug')
197+
cleanTask.dependsOn -= tasks.named('externalNativeBuildCleanProRelease')
198+
}
199+
}
200+
}

0 commit comments

Comments
 (0)