fix(build): clean natives

This commit is contained in:
rhunk 2024-08-11 16:05:07 +02:00
parent f97dda6e4d
commit 43f1a305a2

View File

@ -44,17 +44,9 @@ fun getNativeFiles() = File(projectDir, "build/rustJniLibs/android").listFiles()
abiFolder.takeIf { it.isDirectory }?.listFiles()?.toList() ?: emptyList()
}
tasks.register("cleanNatives") {
doLast {
println("Cleaning native files")
getNativeFiles()?.forEach { file ->
file.deleteRecursively()
}
}
}
tasks.named("preBuild").configure {
dependsOn("cleanNatives", "cargoBuild")
val buildAndRename by tasks.registering {
dependsOn("cargoBuild")
doLast {
getNativeFiles()?.forEach { file ->
if (file.name.endsWith(".so")) {
@ -64,3 +56,17 @@ tasks.named("preBuild").configure {
}
}
}
val cleanNatives by tasks.registering {
finalizedBy(buildAndRename)
doFirst {
println("Cleaning native files")
getNativeFiles()?.forEach { file ->
file.deleteRecursively()
}
}
}
tasks.named("preBuild").configure {
dependsOn(cleanNatives)
}